Skip to content

Commit 9603c2b

Browse files
akoclaude
andcommitted
fix: SEARCH treats /, ., -, : as token separators (BUG 4)
FTS5 tokenizes on these characters, so 'rest/companies' would only match literal 'rest companies'. Now we replace these separators with spaces in the query so each segment becomes a separate AND term. This makes path queries like 'rest/companies' or qualified names like 'Module.Entity' work intuitively. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 13a77b8 commit 9603c2b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mdl/executor/cmd_catalog.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,9 +787,18 @@ func (e *Executor) execSearch(stmt *ast.SearchStmt) error {
787787
}
788788

789789
// escapeFTSQuery escapes special characters in FTS5 queries.
790+
// FTS5 treats characters like '/', '.', '-' as token separators. To make
791+
// queries like 'rest/companies' or 'Module.Entity' usable, we replace these
792+
// with spaces (treated as AND between terms).
790793
func escapeFTSQuery(q string) string {
791794
// Escape single quotes for SQL
792-
return strings.ReplaceAll(q, "'", "''")
795+
q = strings.ReplaceAll(q, "'", "''")
796+
// Replace common path/qualified-name separators with spaces so each segment
797+
// becomes a separate token that FTS5 ANDs together.
798+
for _, sep := range []string{"/", ".", "-", ":"} {
799+
q = strings.ReplaceAll(q, sep, " ")
800+
}
801+
return q
793802
}
794803

795804
// Search performs a full-text search with the specified output format.

0 commit comments

Comments
 (0)