feat(search): Add hybrid search engine with FTS5, vector, and RRF fusion
Implements the search module providing three search modes: - Lexical (FTS5): Full-text search using SQLite FTS5 with safe query sanitization. User queries are automatically tokenized and wrapped in proper FTS5 syntax. Supports a "raw" mode for power users who want direct FTS5 query syntax (NEAR, column filters, etc.). - Semantic (vector): Embeds the search query via Ollama, then performs cosine similarity search against stored document embeddings. Results are deduplicated by doc_id since documents may have multiple chunks. - Hybrid (default): Executes both lexical and semantic searches in parallel, then fuses results using Reciprocal Rank Fusion (RRF) with k=60. This avoids the complexity of score normalization while producing high-quality merged rankings. Gracefully degrades to lexical-only when embeddings are unavailable. Additional components: - search::filters: Post-retrieval filtering by source_type, author, project, labels (AND logic), file path prefix, created_after, and updated_after. Date filters accept relative formats (7d, 2w) and ISO dates. - search::rrf: Reciprocal Rank Fusion implementation with configurable k parameter and optional explain mode that annotates each result with its component ranks and fusion score breakdown. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
14
src/search/mod.rs
Normal file
14
src/search/mod.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
mod filters;
|
||||
mod fts;
|
||||
mod hybrid;
|
||||
mod rrf;
|
||||
mod vector;
|
||||
|
||||
pub use fts::{
|
||||
generate_fallback_snippet, get_result_snippet, search_fts, to_fts_query, FtsQueryMode,
|
||||
FtsResult,
|
||||
};
|
||||
pub use filters::{apply_filters, PathFilter, SearchFilters};
|
||||
pub use rrf::{rank_rrf, RrfResult};
|
||||
pub use vector::{search_vector, VectorResult};
|
||||
pub use hybrid::{search_hybrid, HybridResult, SearchMode};
|
||||
Reference in New Issue
Block a user