Expand description
ANN search with staleness-based re-ranking.
§Search flow (ANN path — preferred)
- Register the sqlite-vec extension via [
crate::vec_ext::register_vec_extension]. - Embed the query with the same model used at index time.
- Ask the
vec_embeddingsvirtual table for the top-crate::store::ANN_CANDIDATE_COUNTnearest vectors. - Re-rank candidates:
score = cosine_sim * (1 - staleness_weight * staleness). - Return top-K results sorted by final score descending.
§Search flow (brute-force fallback)
Steps 2–5 above, but step 3 is replaced by loading all vectors from SQLite
into memory. Used when sqlite-vec is not available or vec_embeddings
does not yet exist (e.g. on the first rebuild before the schema migration).
Structs§
- Search
Hit - One result from a semantic search.
- Stored
Embedding - In-memory representation of a stored embedding row.
Functions§
- parse_
blob - Parse a raw BLOB from the database into a f32 vector via
decode_vector. - rerank
- Re-rank a list of stored embeddings against a query vector.