Method FindMatchingPartitionsAsync
FindMatchingPartitionsAsync(DataSource, float[], int, float, bool, bool, DataFilter, CancellationToken)
Asynchronously finds the top matching partitions in the given data source based on cosine similarity to the provided query vector.
public static Task<List<PartitionSimilarity>> FindMatchingPartitionsAsync(DataSource dataSource, float[] vector, int topK = 3, float minScore = 0.5, bool forceUniqueDataSource = false, bool forceUniqueSection = false, DataFilter filter = null, CancellationToken cancellationToken = default)
Parameters
dataSourceDataSourceA single DataSource to search. Cannot be null.
vectorfloat[]The query embedding vector as an array of floats.
topKintThe maximum number of top results to return. Defaults to 3; minimum value is 1.
minScorefloatThe minimum similarity threshold (0 to 0.99). Results with similarity below this value are discarded.
forceUniqueDataSourceboolIf true, forces returned matches to come from at most one data source.
forceUniqueSectionboolIf true, forces returned matches to come from at most one section per data source.
filterDataFilterOptional DataFilter to exclude specific data sources or sections.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- Task<List<PartitionSimilarity>>
A task that represents the asynchronous search operation. The task result contains a list of PartitionSimilarity objects representing the top matching partitions, or null if none qualify.
Exceptions
- ArgumentNullException
Thrown if
dataSourceis null.
FindMatchingPartitionsAsync(IEnumerable<DataSource>, float[], int, float, bool, bool, DataFilter, CancellationToken)
Asynchronously finds the top matching partitions from the given data sources based on cosine similarity to the provided query vector.
public static Task<List<PartitionSimilarity>> FindMatchingPartitionsAsync(IEnumerable<DataSource> dataSources, float[] vector, int topK = 3, float minScore = 0.5, bool forceUniqueDataSource = false, bool forceUniqueSection = false, DataFilter filter = null, CancellationToken cancellationToken = default)
Parameters
dataSourcesIEnumerable<DataSource>A collection of DataSource instances to search. Cannot be null or empty.
vectorfloat[]The query embedding vector as an array of floats.
topKintThe maximum number of top results to return. Defaults to 3; minimum value is 1.
minScorefloatThe minimum similarity threshold (0 to 0.99). Results with similarity below this value are discarded.
forceUniqueDataSourceboolIf true, forces returned matches to come from at most one data source.
forceUniqueSectionboolIf true, forces returned matches to come from at most one section per data source.
filterDataFilterOptional DataFilter to exclude specific data sources or sections.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- Task<List<PartitionSimilarity>>
A task that represents the asynchronous search operation. The task result contains a list of PartitionSimilarity objects representing the top matching partitions, or null if none qualify.
Exceptions
- ArgumentNullException
Thrown if
dataSourcesis null or contains no elements.