Method FindMatchingPartitions
FindMatchingPartitions(string, int, float, bool, bool, CancellationToken)
Searches for similar partitions across all registered data sources using text similarity.
public List<PartitionSimilarity> FindMatchingPartitions(string text, int topK = 3, float minScore = 0.5, bool forceUniqueDataSource = false, bool forceUniqueSection = false, CancellationToken cancellationToken = default)
Parameters
textstringThe query text to find similar entries for.
topKintMaximum number of results to return. Default is 3.
minScorefloatMinimum similarity score threshold (0.0 to 1.0). Default is 0.5.
forceUniqueDataSourceboolIf
true, all returned results must come from the same DataSource. Default isfalse.forceUniqueSectionboolIf
true, all returned results must come from the same Section. Default isfalse.cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- List<PartitionSimilarity>
A list of PartitionSimilarity objects meeting the specified criteria.
Examples
LM embeddingModel = LM.LoadFromModelID("embeddinggemma-300m");
RagEngine ragEngine = new RagEngine(embeddingModel);
// Import some documents first...
ragEngine.ImportText("Document content here", "docs", "section1");
// Search for similar partitions
var matches = ragEngine.FindMatchingPartitions(
text: "AI research advancements",
topK: 5,
minScore: 0.4f);
Console.WriteLine($"Found {matches.Count} matching partitions.");
Remarks
This method computes embeddings for the input text and performs a vector similarity search against all partitions in the registered data sources.
If a Reranker is configured, results are reranked using the reranking model before the final top-K selection.
Exceptions
- ArgumentNullException
Thrown if no data sources are registered.
- OperationCanceledException
Thrown if the operation is canceled.
FindMatchingPartitions(Attachment, int, float, bool, bool, CancellationToken)
Searches for similar partitions across all registered data sources using attachment content.
public List<PartitionSimilarity> FindMatchingPartitions(Attachment attachment, int topK = 3, float minScore = 0.5, bool forceUniqueDataSource = false, bool forceUniqueSection = false, CancellationToken cancellationToken = default)
Parameters
attachmentAttachmentThe Attachment containing the content to search for.
topKintMaximum number of results to return. Default is 3.
minScorefloatMinimum similarity score threshold (0.0 to 1.0). Default is 0.5.
forceUniqueDataSourceboolIf
true, all returned results must come from the same DataSource. Default isfalse.forceUniqueSectionboolIf
true, all returned results must come from the same Section. Default isfalse.cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- List<PartitionSimilarity>
A list of PartitionSimilarity objects meeting the specified criteria.
Remarks
The attachment's content is converted to embeddings (text or vision, depending on the content type) and a similarity search is performed against all registered data sources.
For vision-enabled attachments, a vision embedding model must be registered with the engine.
Exceptions
- ArgumentNullException
Thrown if no data sources are registered.
- ArgumentException
Thrown if the required embedding model is not available.
- OperationCanceledException
Thrown if the operation is canceled.