Skip to main content

sanitize_fts5_query

Function sanitize_fts5_query 

Source
pub fn sanitize_fts5_query(query: &str) -> (String, String)
Expand description

Sanitizes a free-form user query into (and_query, or_query) formatted for SQLite FTS5. Each alphanumeric/underscore token is quoted and given a prefix wildcard: "token"*. Identifiers are split at case boundaries too (parseHTTPResponse -> parse HTTP Response), so a camelCase query finds a snake_case symbol. Each split identifier keeps its unsplit form as an alternative inside its own required term, so a camelCase symbol, which FTS5 indexes as one token, still matches. A query of two or three words also tries their concatenation. English stop words are dropped unless the whole query is stop words, and tokens under three characters get no prefix wildcard.