pub trait VectorIndex: Send + Sync {
// Required methods
fn search(&self, query: &Embedding, k: usize) -> Vec<IndexResult>;
fn len(&self) -> usize;
fn name(&self) -> &'static str;
fn dim(&self) -> usize;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn search_with_filter(
&self,
query: &Embedding,
k: usize,
filter: &dyn Fn(&str) -> bool,
) -> Vec<IndexResult> { ... }
}Expand description
Trait for vector similarity search indexes
Implementations must be thread-safe (Send + Sync) for use in
async contexts like the sqlx store.
Required Methods§
Provided Methods§
Sourcefn search_with_filter(
&self,
query: &Embedding,
k: usize,
filter: &dyn Fn(&str) -> bool,
) -> Vec<IndexResult>
fn search_with_filter( &self, query: &Embedding, k: usize, filter: &dyn Fn(&str) -> bool, ) -> Vec<IndexResult>
Search with traversal-time filtering.
The predicate receives a chunk_id and returns true to keep the candidate. HNSW overrides this with traversal-time filtering (skips non-matching nodes during graph walk). Default impl over-fetches and post-filters.