Skip to content

fix(retrieval): use content trigram index for corpus.grep - #422

Merged
EricNGOntos merged 1 commit into
mainfrom
fix/wuchengke/grep-content-trigram
Sep 15, 2026
Merged

EricNGOntos merged 1 commit into
mainfrom
fix/wuchengke/grep-content-trigram

Conversation

@EricNGOntos

Copy link
Copy Markdown
Contributor

Summary

  • corpus.grep was joining documents first, so Postgres filtered every in-scope chunk and skipped idx_document_chunks_content_trgm.
  • Match content first via a materialized CTE, then apply current-revision / user scope. Same match set; observed count plan 31.7s → 0.44s on the medical corpus.

Test plan

  • make check
  • Old vs new SQL: HFrEF count 930/930, top-30 ids identical, scoped 68/68, text-only 798/798
  • Backend CI on this PR

Made with Cursor

The planner nested from documents and filtered every in-scope chunk, skipping idx_document_chunks_content_trgm. Match set and current-revision scope are unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@EricNGOntos
EricNGOntos merged commit 7cce49a into main Sep 15, 2026
6 checks passed
@EricNGOntos
EricNGOntos deleted the fix/wuchengke/grep-content-trigram branch September 15, 2026 06:38
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.

1 participant