Expand description
FTS5 query helpers: escaping, stopword stripping, and safe MATCH construction.
User input must never be passed raw to SQLite FTS5: operators like AND,
OR, NEAR, and bare " can change query structure or cause errors.
Natural-language prompts also contain stopwords (why, not, the) that
would force AND-matches to fail when those tokens are absent from notes.
Structs§
- Prepared
Query - Prepared FTS query plus the significant tokens used for ranking boosts.
Functions§
- escape_
fts5_ query - Escape a user query for SQLite FTS5
MATCH(legacy helper). - is_
generic_ topic - True when every token is a generic overview word (or the list is empty).
- prepare_
search_ query - Build a safe FTS5 MATCH string and ranking tokens from raw user input.
- significant_
tokens - Strip stopwords; if nothing remains, fall back to tokens longer than 1 char.
- tokenize_
query - Tokenize raw user text: split on whitespace/punctuation, lowercase, keep alnum/_/-/:/.