-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Description
Is your feature request related to a problem? Please describe.
The new Vector search is really easy to use, but to integrate it with Microsoft.Extensions.AI or other RAG frameworks, usually the similarity score is also required.
Currently neither WhereNear nor TopK returns the score.
Describe the solution you'd like
Make the WhereNear and TopK return both the record and score (or distance), allowing users to select on it.
// Find all documents in this collection where the COS Sim distance is <= 0.3
// based on the values in the object's Embedding property (float[])
var matches = col.Query()
.WhereNear(x => x.Embedding, queryVec, maxDistance: 0.3f)
.Select(x => new VectorSearchResult(x.Record, x.Score))
.ToList();
// Find all documents in the same collection by KNN, returning closest 5
var top5 = col.Query()
.TopK(x => x.Embedding, queryVec, k: 5)
.Select(x => new VectorSearchResult(x.Record, x.Score))
.ToList();