pub struct Searcher { /* private fields */ }Implementations§
Source§impl Searcher
impl Searcher
pub fn load( project_root: &Path, model_id: &str, model_path: &Path, ) -> Result<Self>
pub fn load_with_quantized( project_root: &Path, model_id: &str, model_path: &Path, quantized: bool, ) -> Result<Self>
Sourcepub fn load_from_index_dir(index_dir: &Path, model_path: &Path) -> Result<Self>
pub fn load_from_index_dir(index_dir: &Path, model_path: &Path) -> Result<Self>
Load a searcher from a specific index directory (for parent index use)
Sourcepub fn load_from_index_dir_with_quantized(
index_dir: &Path,
model_path: &Path,
quantized: bool,
) -> Result<Self>
pub fn load_from_index_dir_with_quantized( index_dir: &Path, model_path: &Path, quantized: bool, ) -> Result<Self>
Load a searcher from a specific index directory with quantization option
Sourcepub fn filter_by_path_prefix(&self, prefix: &Path) -> Result<Vec<i64>>
pub fn filter_by_path_prefix(&self, prefix: &Path) -> Result<Vec<i64>>
Filter results to files within a subdirectory prefix. Returns document IDs where file path starts with the given prefix.
Sourcepub fn filter_by_file_patterns(&self, patterns: &[String]) -> Result<Vec<i64>>
pub fn filter_by_file_patterns(&self, patterns: &[String]) -> Result<Vec<i64>>
Get document IDs matching the given file patterns using globset
Sourcepub fn filter_exclude_by_patterns(
&self,
patterns: &[String],
) -> Result<Vec<i64>>
pub fn filter_exclude_by_patterns( &self, patterns: &[String], ) -> Result<Vec<i64>>
Get document IDs for code units that DON’T match exclude patterns (SQL-based) Uses REGEXP to filter out files matching any of the glob-like patterns
Sourcepub fn filter_exclude_by_dirs(&self, dirs: &[String]) -> Result<Vec<i64>>
pub fn filter_exclude_by_dirs(&self, dirs: &[String]) -> Result<Vec<i64>>
Get document IDs for code units NOT in excluded directories (SQL-based) Uses REGEXP to filter out files in any of the specified directories Supports both literal directory names and glob patterns:
- Literal: “vendor”, “node_modules”, “.claude/plugins”
- Glob: “/plugins”, “**/test_”, “**/*_generated”
Sourcepub fn filter_by_files(&self, files: &[String]) -> Result<Vec<i64>>
pub fn filter_by_files(&self, files: &[String]) -> Result<Vec<i64>>
Get document IDs for code units in the given files (exact match)
Sourcepub fn filter_by_text_pattern_with_options(
&self,
pattern: &str,
extended_regexp: bool,
fixed_strings: bool,
word_regexp: bool,
case_sensitive: bool,
) -> Result<Vec<i64>>
pub fn filter_by_text_pattern_with_options( &self, pattern: &str, extended_regexp: bool, fixed_strings: bool, word_regexp: bool, case_sensitive: bool, ) -> Result<Vec<i64>>
Get document IDs for code units containing the given text pattern
Supports grep-compatible pattern matching options:
extended_regexp: Use extended regular expressions (ERE) - supports|,+,?,()etc.fixed_strings: Treat pattern as literal string (no regex), takes precedence over extended_regexpword_regexp: Match whole words only (add word boundaries)
Pattern matching is always case-insensitive. Uses pure SQL queries with REGEXP support for efficient filtering. Automatically converts BRE (Basic Regular Expression) patterns to ERE.
When not in fixed_strings mode, this function runs BOTH regex and literal searches, combining and deduplicating results. This handles cases where users search for code containing regex metacharacters (like parentheses) without escaping them.
Sourcepub fn get_metadata_for_ids(&self, ids: &[i64]) -> Result<Vec<Value>>
pub fn get_metadata_for_ids(&self, ids: &[i64]) -> Result<Vec<Value>>
Get metadata for specific document IDs
Sourcepub fn encode_query(&self, query: &str) -> Result<Array2<f32>>
pub fn encode_query(&self, query: &str) -> Result<Array2<f32>>
Encode a query once for reuse across multiple searches.
Sourcepub fn fts5_search(
&self,
query: &str,
top_k: usize,
subset: Option<&[i64]>,
) -> Option<QueryResult>
pub fn fts5_search( &self, query: &str, top_k: usize, subset: Option<&[i64]>, ) -> Option<QueryResult>
Run FTS5 keyword search if the text index is available and the query remains non-empty after sanitization.
Uses next_plaid::text_search::sanitize_fts5_query_or because the
index is built with next_plaid::FtsTokenizer::IdentifierAware:
each identifier
in the corpus has been pre-split into its compound + camel/snake parts,
so OR semantics let a natural-language query match documents that
contain any relevant sub-part. BM25 still rewards documents that hit
more query terms.
pub fn search( &self, query: &str, top_k: usize, subset: Option<&[i64]>, ) -> Result<Vec<SearchResult>>
Sourcepub fn search_with_embedding(
&self,
query_emb: &Array2<f32>,
top_k: usize,
subset: Option<&[i64]>,
) -> Result<Vec<SearchResult>>
pub fn search_with_embedding( &self, query_emb: &Array2<f32>, top_k: usize, subset: Option<&[i64]>, ) -> Result<Vec<SearchResult>>
Semantic-only search with a pre-computed query embedding.
Sourcepub fn search_hybrid(
&self,
query: &str,
top_k: usize,
subset: Option<&[i64]>,
alpha: f32,
) -> Result<Vec<SearchResult>>
pub fn search_hybrid( &self, query: &str, top_k: usize, subset: Option<&[i64]>, alpha: f32, ) -> Result<Vec<SearchResult>>
Hybrid search: semantic retrieval fused with FTS5 keyword search via RRF.
Sourcepub fn search_hybrid_with_embedding(
&self,
query_emb: &Array2<f32>,
query: &str,
top_k: usize,
subset: Option<&[i64]>,
alpha: f32,
fts5_results: Option<&QueryResult>,
) -> Result<Vec<SearchResult>>
pub fn search_hybrid_with_embedding( &self, query_emb: &Array2<f32>, query: &str, top_k: usize, subset: Option<&[i64]>, alpha: f32, fts5_results: Option<&QueryResult>, ) -> Result<Vec<SearchResult>>
Hybrid search using a pre-computed query embedding and optional cached FTS5 results.
pub fn num_documents(&self) -> usize
Auto Trait Implementations§
impl Freeze for Searcher
impl RefUnwindSafe for Searcher
impl Send for Searcher
impl Sync for Searcher
impl Unpin for Searcher
impl UnsafeUnpin for Searcher
impl UnwindSafe for Searcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more