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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user