Skip to content

[agents] Optimize vector search - #1123

Merged
travlos merged 1 commit into
developfrom
feature/agents/search-tunning
Jul 27, 2026
Merged

[agents] Optimize vector search#1123
travlos merged 1 commit into
developfrom
feature/agents/search-tunning

Conversation

@travlos

@travlos travlos commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Refactored SearchAsync to use a raw SQL query with a CTE and CROSS APPLY for efficient vector distance calculation and top-K retrieval, replacing the LINQ-based approach. Introduced a private SearchResultDto for SQL result mapping. Client-side transformation to RetrievedChunk is unchanged. SourceDocument projection logic was only reformatted, with no functional changes.

Refactored SearchAsync to use a raw SQL query with a CTE and CROSS APPLY for efficient vector distance calculation and top-K retrieval, replacing the LINQ-based approach. Introduced a private SearchResultDto for SQL result mapping. Client-side transformation to RetrievedChunk is unchanged. SourceDocument projection logic was only reformatted, with no functional changes.

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.

Pull request overview

This PR optimizes the Agents document vector retrieval path by replacing the EF/LINQ-based distance query with a raw SQL CTE + CROSS APPLY approach that computes vector distances and retrieves top‑K chunk IDs first, then joins the richer document/blob projections only for those results. It also bumps the Agents package version suffix from beta13 to beta14.

Changes:

  • Refactor DocumentsService.SearchAsync to a raw SQL (;WITH RankedChunks ...) top‑K vector-distance query and map results via a DTO.
  • Keep the client-side projection to RetrievedChunk intact while changing the server-side retrieval strategy.
  • Bump VersionSuffix to beta14 across Agents Core/Server/UI projects.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/Indice.Features.Agents.UI/Indice.Features.Agents.UI.csproj Bumps Agents UI package prerelease suffix to beta14.
src/Indice.Features.Agents.Server/Indice.Features.Agents.Server.csproj Bumps Agents Server package prerelease suffix to beta14.
src/Indice.Features.Agents.Core/Indice.Features.Agents.Core.csproj Bumps Agents Core package prerelease suffix to beta14.
src/Indice.Features.Agents.Core/Services/DocumentsService.cs Replaces LINQ-based vector search with CTE + CROSS APPLY SQL and adds a DTO for result materialization.

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

Comment thread src/Indice.Features.Agents.Core/Services/DocumentsService.cs

@VSpyridonos VSpyridonos 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.

🚀

@travlos
travlos merged commit 19b4fae into develop Jul 27, 2026
8 checks passed
@travlos
travlos deleted the feature/agents/search-tunning branch July 27, 2026 12:53
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.

3 participants