Skip to content

feat: Add VectorSearchWithScoreAsync to expose cosine similarity distance - #131

Merged
mrdevrobot merged 1 commit into
mainfrom
copilot/add-similarity-score-in-vector-search
Jul 24, 2026
Merged

feat: Add VectorSearchWithScoreAsync to expose cosine similarity distance#131
mrdevrobot merged 1 commit into
mainfrom
copilot/add-similarity-score-in-vector-search

Conversation

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

DocumentCollection.VectorSearchAsync silently discards the Distance field from VectorSearchResult, making it impossible to threshold or rank results by relevance from the typed API.

Changes

  • IDocumentCollection<TId, T> — adds VectorSearchWithScoreAsync returning IAsyncEnumerable<(T Document, float Distance)>
  • DocumentCollection<TId, T> — implements the method by forwarding result.Distance alongside the fetched document
  • ICollectionIndex<TId, T> / CollectionSecondaryIndex — exposes the raw VectorSearchResult stream needed by the new overload

Usage

await foreach (var (doc, score) in collection.VectorSearchWithScoreAsync("embedding", queryVector, k: 10))
{
    if (score < 0.35f) // cosine distance threshold
        yield return doc;
}

Copilot AI changed the title [WIP] Expose similarity score in VectorSearchAsync method feat: Add VectorSearchWithScoreAsync to expose cosine similarity distance Jul 24, 2026
Copilot AI requested a review from mrdevrobot July 24, 2026 14:58
@mrdevrobot
mrdevrobot marked this pull request as ready for review July 24, 2026 15:00
Copilot AI review requested due to automatic review settings July 24, 2026 15:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mrdevrobot
mrdevrobot merged commit c9c468d into main Jul 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DocumentCollection<TId,T>.VectorSearchAsync does not expose similarity score (distance)

3 participants