You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change ITextSearch<TRecord>.GetSearchResultsAsync to return KernelSearchResults<TRecord>
- Change interface return type from KernelSearchResults<object> to KernelSearchResults<TRecord>
- Update VectorStoreTextSearch implementation with new GetResultsAsTRecordAsync helper
- Keep GetResultsAsRecordAsync for legacy ITextSearch interface backward compatibility
- Update 3 unit tests to use strongly-typed DataModel instead of object
Benefits:
- Improved type safety - no more casting required
- Better IntelliSense and developer experience
- Zero breaking changes to legacy ITextSearch interface
- All 19 unit tests pass
This is Part 2.1 of the Issue #10456 multi-PR chain, refining the API .
/// Perform a search for content related to the specified query and return <see cref="object"/> values representing the search results.
39
+
/// Perform a search for content related to the specified query and return strongly-typed <typeparamref name="TRecord"/> values representing the search results.
40
40
/// </summary>
41
41
/// <param name="query">What to search for.</param>
42
42
/// <param name="searchOptions">Options used when executing a text search.</param>
43
43
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
Copy file name to clipboardExpand all lines: dotnet/src/SemanticKernel.UnitTests/Data/VectorStoreTextSearchTests.cs
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -78,12 +78,14 @@ public async Task CanGetSearchResultAsync()
78
78
{
79
79
// Arrange.
80
80
varsut=awaitCreateVectorStoreTextSearchAsync();
81
+
ITextSearch<DataModel>typeSafeInterface=sut;
81
82
82
83
// Act.
83
-
KernelSearchResults<object>searchResults=awaitsut.GetSearchResultsAsync("What is the Semantic Kernel?",new(){Top=2,Skip=0});
84
+
KernelSearchResults<DataModel>searchResults=awaittypeSafeInterface.GetSearchResultsAsync("What is the Semantic Kernel?",newTextSearchOptions<DataModel>{Top=2,Skip=0});
KernelSearchResults<object>searchResults=awaitsut.GetSearchResultsAsync("What is the Semantic Kernel?",new(){Top=2,Skip=0});
125
+
KernelSearchResults<DataModelWithRawEmbedding>searchResults=awaittypeSafeInterface.GetSearchResultsAsync("What is the Semantic Kernel?",newTextSearchOptions<DataModelWithRawEmbedding>{Top=2,Skip=0});
0 commit comments