Files
Garry TanandClaude Fable 5 5882d5261a fix(search): match both slash-split and literal slash forms in FTS queries (#2380 review)
Review finding on the normalize-only approach: Postgres' text-search
parser emits the joined file-alias lexeme on the INDEX side too
(to_tsvector('english','acme/widget') -> 'acme/widget'), so replacing
'/' with whitespace in the query made documents containing the literal
slash form (file paths, URLs, pasted titles) unreachable — the split-word
AND pass can't match the joined lexeme and the OR fallback can't either.
Pre-fix, those exact-form queries DID match.

Replace the TS-side normalizeKeywordQuery with buildWebsearchQueryExpr
in sql-ranking.ts (shared by both engines, keeping them in lockstep): a
slash-bearing query now binds the raw text once and matches
(websearch_to_tsquery(translate($1,'/',' ')) || websearch_to_tsquery($1))
— split-word prose AND literal slash forms alike. Slash-free queries keep
the byte-identical single-parse SQL and identical ts_rank.

New regression test pins the literal-slash arm (verified failing under
the normalize-only expression); the two AND-vs-OR slash tests still pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 11:35:32 -07:00
..