Skip to main content

Module search

Module search 

Source
Expand description

ANN search with staleness-based re-ranking.

§Search flow (ANN path — preferred)

  1. Register the sqlite-vec extension via [crate::vec_ext::register_vec_extension].
  2. Embed the query with the same model used at index time.
  3. Ask the vec_embeddings virtual table for the top-crate::store::ANN_CANDIDATE_COUNT nearest vectors.
  4. Re-rank candidates: score = cosine_sim * (1 - staleness_weight * staleness).
  5. 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§

SearchHit
One result from a semantic search.
StoredEmbedding
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.