fix(search): use explicit AND in FTS5 queries to fix apostrophe search

FTS5's implicit AND (space-separated tokens) silently fails when combined
with parenthesized OR groups produced by processPunctuatedWords. For example,
searching "you've got" generated the query `("you ve" OR youve*) got*` which
returned no results. Using explicit AND (`("you ve" OR youve*) AND got*`)
resolves this FTS5 quirk. Since implicit and explicit AND are semantically
identical in FTS5, this change is safe for all queries unconditionally.
This commit is contained in:
Deluan
2026-03-26 20:15:28 -04:00
parent 33e20d355e
commit ccee33f474
2 changed files with 18 additions and 15 deletions
+3 -1
View File
@@ -178,7 +178,9 @@ func buildFTS5Query(userInput string) string {
tokens[i] = t + "*"
}
result = strings.Join(tokens, " ")
// Use explicit AND between tokens — FTS5's implicit AND (space-separated)
// doesn't work correctly with parenthesized OR groups from processPunctuatedWords.
result = strings.Join(tokens, " AND ")
for i, phrase := range phrases {
placeholder := fmt.Sprintf("\x00PHRASE%d\x00", i)