Skip to main content

Searcher

Struct Searcher 

Source
pub struct Searcher { /* private fields */ }

Implementations§

Source§

impl Searcher

Source

pub fn load( project_root: &Path, model_id: &str, model_path: &Path, ) -> Result<Self>

Source

pub fn load_with_quantized( project_root: &Path, model_id: &str, model_path: &Path, quantized: bool, ) -> Result<Self>

Source

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)

Source

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

Source

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.

Source

pub fn filter_by_file_patterns(&self, patterns: &[String]) -> Result<Vec<i64>>

Get document IDs matching the given file patterns using globset

Source

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

Source

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”
Source

pub fn filter_by_files(&self, files: &[String]) -> Result<Vec<i64>>

Get document IDs for code units in the given files (exact match)

Source

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_regexp
  • word_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.

Source

pub fn get_metadata_for_ids(&self, ids: &[i64]) -> Result<Vec<Value>>

Get metadata for specific document IDs

Source

pub fn encode_query(&self, query: &str) -> Result<Array2<f32>>

Encode a query once for reuse across multiple searches.

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.

Source

pub fn search( &self, query: &str, top_k: usize, subset: Option<&[i64]>, ) -> Result<Vec<SearchResult>>

Source

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.

Source

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.

Source

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.

Source

pub fn num_documents(&self) -> usize

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more