Share via


IVectorSearchable<TRecord>.SearchAsync<TInput> Method

Definition

Searches the vector store for records that are similar to the given value.

public System.Collections.Generic.IAsyncEnumerable<Microsoft.Extensions.VectorData.VectorSearchResult<TRecord>> SearchAsync<TInput>(TInput searchValue, int top, Microsoft.Extensions.VectorData.VectorSearchOptions<TRecord>? options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member SearchAsync : 'Input * int * Microsoft.Extensions.VectorData.VectorSearchOptions<'Record> * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.Extensions.VectorData.VectorSearchResult<'Record>>
Public Function SearchAsync(Of TInput) (searchValue As TInput, top As Integer, Optional options As VectorSearchOptions(Of TRecord) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of VectorSearchResult(Of TRecord))

Type Parameters

TInput

The type of the input value on which to perform the similarity search.

Parameters

searchValue
TInput

The value on which to perform the similarity search. See the remarks section for more details.

top
Int32

The maximum number of results to return.

options
VectorSearchOptions<TRecord>

The options that control the behavior of the search.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

The records found by the vector search, including their result scores.

Remarks

The types supported for the searchValue vary based on the provider being used and the embedding generation configured:

Applies to