Module search

Module search 

Source
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

  1. Fetch candidate_k_keyword keyword candidates (BM25 rank).
  2. Fetch candidate_k_vector vector candidates (cosine similarity).
  3. Normalize both sets to [0, 1] using min-max normalization.
  4. Merge: score = (1 - α) × keyword + α × semantic.
  5. Group by document (MAX aggregation).
  6. Sort by score (desc), updated_at (desc), id (asc).
  7. Truncate to final_limit.

Structs§

ScoreExplanation
Scoring breakdown for a search result.
SearchParams
Retrieval tuning parameters, decoupled from application config.
SearchRequest
Bundles all inputs for a single search invocation.
SearchResultItem
A search result matching the SCHEMAS.md context.search response 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 Store backend.