Skip to main content

prepare_search_query

Function prepare_search_query 

Source
pub fn prepare_search_query(raw: &str) -> Result<PreparedQuery>
Expand description

Build a safe FTS5 MATCH string and ranking tokens from raw user input.

Strategy:

  1. Tokenize (punctuation-safe)
  2. Prefer significant (non-stopword) tokens
  3. Single token → exact quoted match
  4. Multiple tokens → OR between them for natural-language recall (documents rarely contain every filler word from a full question)

§Errors

Returns BrainError::FtsQuery when no usable token remains.