Expand description
FTS5 full-text search with BM25 ranking.
This module provides search helpers on top of the items_fts FTS5 virtual
table defined in super::schema. The FTS5 table is automatically kept
in sync with the items table via INSERT/UPDATE/DELETE triggers.
§Column Weights (BM25)
| Column | Weight | Rationale |
|---|---|---|
| title | 3.0 | Most specific, short, high signal |
| description | 2.0 | Detailed context, moderate signal |
| labels | 1.0 | Namespace tags, low cardinality |
§Tokenizer
Porter stemmer + unicode61 tokenizer with prefix indexes on 2 and 3
characters. This supports:
- Stemming: searching “running” matches “run”, “runs”, “runner”
- Prefix search: “auth*” matches “authentication”, “authorize”
- Unicode: full Unicode word-breaking
§Performance
Sub-1ms query time at Tier S (≤1k items). FTS5 lookups are O(log N) via the b-tree index and prefix tables.
Constants§
- BM25_
WEIGHT_ DESCRIPTION - BM25_
WEIGHT_ LABELS - BM25_
WEIGHT_ TITLE - Default BM25 column weights: title=3, description=2, labels=1.
Functions§
- fts_
in_ sync - Validate that the FTS5 index is in sync with the
itemstable. - fts_
row_ count - Return the number of rows in the FTS5 index.
- rebuild_
fts_ index - Rebuild the FTS5 index from the current
itemstable. - search_
bm25 - Search the FTS5 index with BM25 ranking and column weights.