perf: bound classic BM25 candidates with Postgres FTS - #252
Merged
Merged
Conversation
Classic path/content channels loaded the full scoped corpus into Python before BM25. Prefetch via simple FTS (server-side OR tsquery), apply section exclusions before the candidate LIMIT, and fall back to a full scan when FTS matches nothing so recall does not regress. Combines the approaches from #244 and #251; closes #195. Co-authored-by: Ray Tien <ray.tien0907@gmail.com> Co-authored-by: nuemaan <anonnumaan@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Aug 11, 2026
EricNGOntos
added a commit
that referenced
this pull request
Aug 11, 2026
Keep map-nav default retrieval docs; retain BM25 FTS candidate limit note. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
path/contentBM25 channels now prefilter with PostgressimpleFTS (bounded byRETRIEVAL_POSTGRES_FTS_CANDIDATE_LIMIT, default 2000), then keep Python BM25 as the final channel ranker.exclude_sectionsbeforeLIMIT,.env.example, channel unit coverage) and #251 (server-side OR tsquery fromtext[], full-scan fallback to preserve recall, real Postgres contract tests).use_agentic=false).Co-authored-by.Test plan
uv run pytest apps/api/tests/unit/test_bm25_channel_tsquery.py packages/shared-python/shared/tests/test_retrieval_search_channels.py -quv run pytest apps/api/tests/contract/test_bm25_fts_prefilter_contract.py -quse_agentic=false) on a larger namespace if availableMade with Cursor