ragfs_query/lib.rs
1//! # ragfs-query
2//!
3//! Query parsing and execution for RAGFS semantic search.
4//!
5//! This crate handles the query pipeline: parsing natural language queries,
6//! generating query embeddings, and executing similarity searches against the vector store.
7//!
8//! ## Features
9//!
10//! - **Natural language queries**: Search with plain text like "authentication logic"
11//! - **Semantic matching**: Uses vector similarity (cosine distance)
12//! - **Hybrid search**: Combine vector similarity with full-text search
13//! - **Filtering**: Narrow results by path, MIME type, or date range
14//!
15//! ## Usage
16//!
17//! ```rust,ignore
18//! use ragfs_query::QueryExecutor;
19//! use ragfs_core::{VectorStore, Embedder};
20//! use std::sync::Arc;
21//!
22//! // Create the query executor
23//! let executor = QueryExecutor::new(
24//! store, // Arc<dyn VectorStore>
25//! embedder, // Arc<dyn Embedder>
26//! 10, // Default result limit
27//! true, // Enable hybrid search
28//! );
29//!
30//! // Execute a semantic query
31//! let results = executor.execute("error handling implementation").await?;
32//!
33//! for result in results {
34//! println!("{}: {:.3}", result.file_path.display(), result.score);
35//! println!(" {}", result.content);
36//! }
37//! ```
38//!
39//! ## Query Pipeline
40//!
41//! 1. **Parse**: Extract query text and optional filters
42//! 2. **Embed**: Convert query text to a 384-dimensional vector
43//! 3. **Search**: Find similar chunks using ANN (approximate nearest neighbors)
44//! 4. **Rank**: Order results by similarity score
45//! 5. **Return**: Provide results with content, scores, and locations
46//!
47//! ## Hybrid Search
48//!
49//! When enabled, combines:
50//! - **Vector similarity**: Semantic matching via embeddings
51//! - **Full-text search**: Keyword matching for precision
52//!
53//! Results are fused using reciprocal rank fusion (RRF).
54//!
55//! ## Components
56//!
57//! | Type | Description |
58//! |------|-------------|
59//! | [`QueryExecutor`] | Executes semantic queries against the index |
60//! | [`QueryParser`] | Parses query strings with optional filters |
61
62pub mod executor;
63pub mod parser;
64
65pub use executor::QueryExecutor;
66pub use parser::QueryParser;