Skip to content

Commit fbdbaab

Browse files
authored
.Net: Fix top/skip bug in Azure AI Search (#13326)
### Motivation and Context #13324 ### Description - Fix top/skip bug in Azure AI Search ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
1 parent c804629 commit fbdbaab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

dotnet/src/VectorData/AzureAISearch/AzureAISearchCollection.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ public override async IAsyncEnumerable<VectorSearchResult<TRecord>> SearchAsync<
400400
options,
401401
top,
402402
floatVector is null
403-
? new VectorizableTextQuery((string)(object)searchValue) { KNearestNeighborsCount = top, Fields = { vectorProperty.StorageName } }
404-
: new VectorizedQuery(floatVector.Value) { KNearestNeighborsCount = top, Fields = { vectorProperty.StorageName } });
403+
? new VectorizableTextQuery((string)(object)searchValue) { KNearestNeighborsCount = top + options.Skip, Fields = { vectorProperty.StorageName } }
404+
: new VectorizedQuery(floatVector.Value) { KNearestNeighborsCount = top + options.Skip, Fields = { vectorProperty.StorageName } });
405405

406406
await foreach (var record in this.SearchAndMapToDataModelAsync(null, searchOptions, options.IncludeVectors, cancellationToken).ConfigureAwait(false))
407407
{
@@ -442,8 +442,8 @@ public async IAsyncEnumerable<VectorSearchResult<TRecord>> HybridSearchAsync<TIn
442442
},
443443
top,
444444
floatVector is null
445-
? new VectorizableTextQuery((string)(object)searchValue) { KNearestNeighborsCount = top, Fields = { vectorProperty.StorageName } }
446-
: new VectorizedQuery(floatVector.Value) { KNearestNeighborsCount = top, Fields = { vectorProperty.StorageName } });
445+
? new VectorizableTextQuery((string)(object)searchValue) { KNearestNeighborsCount = top + options.Skip, Fields = { vectorProperty.StorageName } }
446+
: new VectorizedQuery(floatVector.Value) { KNearestNeighborsCount = top + options.Skip, Fields = { vectorProperty.StorageName } });
447447

448448
searchOptions.SearchFields.Add(textDataProperty.StorageName);
449449
var keywordsCombined = string.Join(" ", keywords);

0 commit comments

Comments
 (0)