Skip to content

Commit

Permalink
Bump Azure.Search.Documents from 11.5.0-beta.5 to 11.5.0 (#165)
Browse files Browse the repository at this point in the history
## Motivation and Context (Why the change? What's the scenario?)
Update to the latest `Azure.Search.Documents` version.

## High level description (Approach, Design)
Update package version and fix associated regressions (mostly naming).
  • Loading branch information
anthonypuppo authored Nov 22, 2023
1 parent ea0b94e commit 8ee959a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Azure.AI.FormRecognizer" Version="4.1.0"/>
<PackageVersion Include="Azure.Search.Documents" Version="11.5.0-beta.5"/>
<PackageVersion Include="Azure.Search.Documents" Version="11.5.0"/>
<PackageVersion Include="Azure.Identity" Version="1.10.4"/>
<PackageVersion Include="Azure.Storage.Blobs" Version="12.19.1"/>
<PackageVersion Include="Azure.Storage.Queues" Version="12.17.1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ await client.IndexDocumentsAsync(

var client = this.GetSearchClient(index);

RawVectorQuery vectorQuery = new()
VectorizedQuery vectorQuery = new(embedding.Data)
{
KNearestNeighborsCount = limit,
Vector = embedding.Data.ToArray(),
Fields = { AzureCognitiveSearchMemoryRecord.VectorField },
// Exhaustive search is a brute force comparison across all vectors,
// ignoring the index, which can be much slower once the index contains a lot of data.
Expand All @@ -144,9 +143,12 @@ await client.IndexDocumentsAsync(

SearchOptions options = new()
{
VectorQueries = { vectorQuery },
// Default, applies the vector query AFTER the search filter
VectorFilterMode = VectorFilterMode.PreFilter
VectorSearch = new()
{
Queries = { vectorQuery },
// Default, applies the vector query AFTER the search filter
FilterMode = VectorFilterMode.PreFilter
}
};

// Remove empty filters
Expand Down Expand Up @@ -201,7 +203,7 @@ public async IAsyncEnumerable<MemoryRecord> GetListAsync(
// Remove empty filters
filters = filters?.Where(f => !f.IsEmpty()).ToList();

var options = new SearchOptions();
SearchOptions options = new();
if (filters is { Count: > 0 })
{
options.Filter = BuildSearchFilter(filters);
Expand Down Expand Up @@ -452,7 +454,7 @@ private SearchIndex PrepareIndexSchema(string index, VectorDbSchema schema)
},
Algorithms =
{
new HnswVectorSearchAlgorithmConfiguration(VectorSearchConfigName)
new HnswAlgorithmConfiguration(VectorSearchConfigName)
{
Parameters = new HnswParameters
{
Expand Down Expand Up @@ -485,7 +487,7 @@ private SearchIndex PrepareIndexSchema(string index, VectorDbSchema schema)
IsFacetable = false,
IsSortable = false,
VectorSearchDimensions = field.VectorSize,
VectorSearchProfile = VectorSearchProfileName,
VectorSearchProfileName = VectorSearchProfileName,
};

break;
Expand Down
6 changes: 3 additions & 3 deletions service/tests/azure-cognitive-search-tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private static async Task CreateIndexAsync(string name)
},
Algorithms =
{
new HnswVectorSearchAlgorithmConfiguration(VectorSearchConfigName)
new HnswAlgorithmConfiguration(VectorSearchConfigName)
{
Parameters = new HnswParameters
{
Expand Down Expand Up @@ -185,7 +185,7 @@ private static async Task CreateIndexAsync(string name)
IsFacetable = false,
IsSortable = false,
VectorSearchDimensions = EmbeddingSize,
VectorSearchProfile = VectorSearchProfileName,
VectorSearchProfileName = VectorSearchProfileName,
});

try
Expand Down Expand Up @@ -253,7 +253,7 @@ private static async Task<IList<MemoryRecord>> SearchByFieldValueAsync(

fieldValue1 = fieldValue1.Replace("'", "''", StringComparison.Ordinal);
fieldValue2 = fieldValue2.Replace("'", "''", StringComparison.Ordinal);
var options = new SearchOptions
SearchOptions options = new()
{
Filter = fieldIsCollection
? $"{fieldName}/any(s: s eq '{fieldValue1}') and {fieldName}/any(s: s eq '{fieldValue2}')"
Expand Down

0 comments on commit 8ee959a

Please sign in to comment.