You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tg messages search treats the whole query as one phrase #84
escapeFts5Query in src/db/messages-search.ts wraps every query in double quotes, so FTS5 reads it as one phrase. Checked on an in-memory FTS5 table with the same escaping (SQLite 3.54.0):
Query
Matches with the escaping
Without it
error OR timeout
0
2
sender:alice
0
3
hel*
0
1
квартир*
0
2
So the operators, column filters and prefixes that --help and docs/search.md describe don't work, hello world finds only messages where the two words stand next to each other, and there is no way to reach other word forms (квартира, квартиру) with a prefix. A query FTS5 can't parse would also come back as TELEGRAM_ERROR.
Proposed:
A query without FTS5 syntax matches messages that contain every word, in any order. Each word is quoted, so punctuation (don't, e-mail) never causes a syntax error.
A query with FTS5 syntax ("a phrase", OR, NOT, NEAR, column:, prefix*, parentheses) goes to FTS5 as written. A syntax error returns INVALID_ARGS with a suggestion.
--phrase keeps today's behaviour: the whole query as one phrase.
--help, docs/search.md and docs/cli-commands.md describe the rules with examples, including word* for other word forms.
Done when e2e tests cover every row of the table, a Cyrillic prefix, punctuation in a plain query and a syntax error.
Activity
fix(search): read the query with FTS5 syntax, plain words in any order
fix(search): C++ as a plain word, snippets folded and cut like the index
fix(search): read the query with FTS5 syntax, plain words in any order
fix(search): C++ as a plain word, snippets folded and cut like the index