Skip to content

Update vector search docs for VectorSearch() API changes (dotnet/efcore#38075)#5325

Draft
Copilot wants to merge 1 commit intopreview.4from
copilot/update-docs-whats-new-sql-server
Draft

Update vector search docs for VectorSearch() API changes (dotnet/efcore#38075)#5325
Copilot wants to merge 1 commit intopreview.4from
copilot/update-docs-whats-new-sql-server

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 11, 2026

The topN parameter was removed from VectorSearch() in dotnet/efcore#38075. Users now compose with standard LINQ operators instead, and SQL Server generates TOP(...) WITH APPROXIMATE rather than TOP_N inside VECTOR_SEARCH().

Changes

  • vector-search.md: Replaced all VectorSearch(..., topN: n) calls with .OrderBy(r => r.Distance).Take(n) pattern, updated generated SQL examples, updated hybrid search example (both C# and SQL)
  • whatsnew.md (EF Core 11): Same API update for the what's new code snippet and description

New pattern

// Before
var blogs = await context.Blogs
    .VectorSearch(b => b.Embedding, embedding, "cosine", topN: 5)
    .ToListAsync();

// After
var blogs = await context.Blogs
    .VectorSearch(b => b.Embedding, embedding, "cosine")
    .OrderBy(r => r.Distance)
    .Take(5)
    .ToListAsync();

Generated SQL now uses SELECT TOP(@p) WITH APPROXIMATE instead of TOP_N = @p inside the VECTOR_SEARCH() TVF.

… (removal of topN parameter)

The topN parameter was removed from VectorSearch() in dotnet/efcore#38075.
Users now compose with .OrderBy(r => r.Distance).Take(n) instead.
SQL Server generates TOP(...) WITH APPROXIMATE rather than TOP_N inside VECTOR_SEARCH().

Agent-Logs-Url: https://github.com/dotnet/EntityFramework.Docs/sessions/a44e53cf-0113-4f96-b07b-4e403b6e0e9b

Co-authored-by: roji <1862641+roji@users.noreply.github.com>
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.

2 participants