pub trait VectorStore {
type Error: Error + Send + Sync + 'static;
// Required methods
fn add_vector(
&mut self,
id: String,
vector: Vec<f32>,
metadata: VectorMetadata,
) -> Result<()>;
fn add_vectors_batch(&mut self, vectors: VectorBatch) -> Result<()>;
fn search(
&self,
query_vector: &[f32],
k: usize,
) -> Result<Vec<SearchResult>>;
fn search_with_threshold(
&self,
query_vector: &[f32],
k: usize,
threshold: f32,
) -> Result<Vec<SearchResult>>;
fn remove_vector(&mut self, id: &str) -> Result<bool>;
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
}Expand description
Vector similarity search abstraction for finding similar embeddings
§Synchronous Version
This trait provides synchronous operations for vector search.
Required Associated Types§
Required Methods§
Sourcefn add_vector(
&mut self,
id: String,
vector: Vec<f32>,
metadata: VectorMetadata,
) -> Result<()>
fn add_vector( &mut self, id: String, vector: Vec<f32>, metadata: VectorMetadata, ) -> Result<()>
Add a vector with associated ID and metadata
Sourcefn add_vectors_batch(&mut self, vectors: VectorBatch) -> Result<()>
fn add_vectors_batch(&mut self, vectors: VectorBatch) -> Result<()>
Add multiple vectors in batch
Sourcefn search(&self, query_vector: &[f32], k: usize) -> Result<Vec<SearchResult>>
fn search(&self, query_vector: &[f32], k: usize) -> Result<Vec<SearchResult>>
Search for k most similar vectors
Sourcefn search_with_threshold(
&self,
query_vector: &[f32],
k: usize,
threshold: f32,
) -> Result<Vec<SearchResult>>
fn search_with_threshold( &self, query_vector: &[f32], k: usize, threshold: f32, ) -> Result<Vec<SearchResult>>
Search with distance threshold
Sourcefn remove_vector(&mut self, id: &str) -> Result<bool>
fn remove_vector(&mut self, id: &str) -> Result<bool>
Remove a vector by ID