Expand description
Search engine with keyword, semantic, and hybrid retrieval modes.
The core search algorithm operates entirely through the Store trait,
with no database or configuration dependencies. The calling application
is responsible for embedding queries, constructing SearchParams,
and passing the appropriate store implementation.
§Hybrid Scoring Algorithm
- Fetch
candidate_k_keywordkeyword candidates (BM25 rank). - Fetch
candidate_k_vectorvector candidates (cosine similarity). - Normalize both sets to
[0, 1]using min-max normalization. - Merge:
score = (1 - α) × keyword + α × semantic. - Group by document (MAX aggregation).
- Sort by score (desc), updated_at (desc), id (asc).
- Truncate to
final_limit.
Structs§
- Score
Explanation - Scoring breakdown for a search result.
- Search
Params - Retrieval tuning parameters, decoupled from application config.
- Search
Request - Bundles all inputs for a single search invocation.
- Search
Result Item - A search result matching the
SCHEMAS.mdcontext.searchresponse shape.
Functions§
- format_
ts_ iso - Format a Unix timestamp as ISO 8601.
- normalize_
scores - Min-max normalize raw scores to
[0.0, 1.0]. - search
- Run a hybrid search against a
Storebackend.