VectorStore

Trait VectorStore 

Source
pub trait VectorStore: Send + Sync {
    // Required methods
    fn upsert<'life0, 'async_trait>(
        &'life0 self,
        documents: Vec<EmbeddedDocument>,
    ) -> Pin<Box<dyn Future<Output = Result<UpsertStats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn search<'life0, 'async_trait>(
        &'life0 self,
        query_embedding: Vec<f32>,
        filter: Option<Filter>,
        top_k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete<'life0, 'async_trait>(
        &'life0 self,
        ids: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<DeleteStats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get<'life0, 'async_trait>(
        &'life0 self,
        ids: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<EmbeddedDocument>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn count<'life0, 'async_trait>(
        &'life0 self,
        filter: Option<Filter>,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<HealthStatus>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn backend_name(&self) -> &'static str;

    // Provided method
    fn dimensions(&self) -> Option<usize> { ... }
}
Expand description

Trait for vector storage backends

Implementors provide vector similarity search with metadata filtering. All operations are async to support both local and remote backends.

Required Methods§

Source

fn upsert<'life0, 'async_trait>( &'life0 self, documents: Vec<EmbeddedDocument>, ) -> Pin<Box<dyn Future<Output = Result<UpsertStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Insert or update documents in the store

Documents with existing IDs will be updated, new IDs will be inserted.

Source

fn search<'life0, 'async_trait>( &'life0 self, query_embedding: Vec<f32>, filter: Option<Filter>, top_k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Search for similar vectors

§Arguments
  • query_embedding - The query vector to find similar documents for
  • filter - Optional metadata filter to narrow results
  • top_k - Maximum number of results to return
§Returns

Results sorted by descending similarity score

Source

fn delete<'life0, 'async_trait>( &'life0 self, ids: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<DeleteStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete documents by ID

Source

fn get<'life0, 'async_trait>( &'life0 self, ids: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<Vec<EmbeddedDocument>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get documents by ID

Source

fn count<'life0, 'async_trait>( &'life0 self, filter: Option<Filter>, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Count documents, optionally filtered

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HealthStatus>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check backend health/connectivity

Source

fn backend_name(&self) -> &'static str

Get the name of this backend (for logging/debugging)

Provided Methods§

Source

fn dimensions(&self) -> Option<usize>

Get configured vector dimensions (if known)

Implementors§