Skip to main content

VectorStore

Trait VectorStore 

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

Source

type Error: Error + Send + Sync + 'static

The error type returned by vector store operations

Required Methods§

Source

fn add_vector( &mut self, id: String, vector: Vec<f32>, metadata: VectorMetadata, ) -> Result<()>

Add a vector with associated ID and metadata

Source

fn add_vectors_batch(&mut self, vectors: VectorBatch) -> Result<()>

Add multiple vectors in batch

Source

fn search(&self, query_vector: &[f32], k: usize) -> Result<Vec<SearchResult>>

Search for k most similar vectors

Source

fn search_with_threshold( &self, query_vector: &[f32], k: usize, threshold: f32, ) -> Result<Vec<SearchResult>>

Search with distance threshold

Source

fn remove_vector(&mut self, id: &str) -> Result<bool>

Remove a vector by ID

Source

fn len(&self) -> usize

Get vector count

Source

fn is_empty(&self) -> bool

Check if empty

Implementors§