Search Modes — Lexical, Semantic, Hybrid
271 words1 min read4 subsectionsFrom the README at ft 0.15.21
On this page4
ft search and ft robot search support three modes, selected via --mode:
| Mode | Backend | Best for | Latency target |
|---|---|---|---|
lexical (default) |
SQLite FTS5 | Known strings, exact errors, identifiers | <10 ms |
semantic |
FNV-1a hash embeddings (fnv1a-hash-128) |
Token-overlap similarity on reworded queries; not true paraphrase understanding | vector scan over stored embeddings |
hybrid |
RRF fusion of lexical + semantic | Best of both; recommended when in doubt | lexical + semantic + fusion overhead |
Lexical (FTS5 + Tantivy)
SQLite FTS5 indexes captured output at write time. A Tantivy secondary index exists as a separate crate but is not populated on the production path.
Semantic (hash embeddings)
Every appended segment also gets a 128-dimension FNV-1a hash embedding (fnv1a-hash-128) stored alongside it. Queries are embedded the same way and matched by vector similarity. This is a lexical-flavored semantic lane, not an ML model; fastembed and the embedder daemon are not on the production path.
It sits behind the semantic-search feature, which the ft binary enables by default; without it, semantic and hybrid modes return lexical-only results.
Hybrid (RRF fusion)
Hybrid mode runs both backends in parallel and fuses results with Reciprocal Rank Fusion (RRF):
score(doc) = sum over backends of 1 / (k + rank_in_backend(doc))
k defaults to 60 (the canonical RRF constant). Hybrid mode is the recommended default when you don't know in advance whether a query is best served by exact matching or by the looser token-overlap recall of the hash-embedding lane. The cost is roughly lexical_latency + semantic_latency + small fusion overhead.
Future-query recall caveat
The current recall bound for semantic search on held-out data is a vacuous PAC-Bayes bound until production query data is collected (derivation, artifact). Treat semantic recall claims as benchmark-substrate only, not production-data-validated, until the bound is non-vacuous.