Skip to main content

VectorStore

Trait VectorStore 

Source
pub trait VectorStore: Send + Sync {
    // Required methods
    fn upsert<'life0, 'async_trait>(
        &'life0 self,
        id: FactId,
        embedding: Vec<f32>,
        metadata: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn search<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        query: &'life1 [f32],
        filter: &'life2 VectorFilter,
        top_k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorMatch>, MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete<'life0, 'async_trait>(
        &'life0 self,
        id: FactId,
    ) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete_by_scope<'life0, 'life1, 'async_trait>(
        &'life0 self,
        scope: &'life1 Scope,
    ) -> Pin<Box<dyn Future<Output = Result<u64, MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Semantic vector storage and nearest-neighbour search.

Implementations MUST be Send + Sync so that Arc<dyn VectorStore> can be shared across async tasks. All methods are fallible and return Result<_, MemoryError>.

Required Methods§

Source

fn upsert<'life0, 'async_trait>( &'life0 self, id: FactId, embedding: Vec<f32>, metadata: Value, ) -> Pin<Box<dyn Future<Output = Result<(), MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Insert or replace the embedding for id.

embedding must have the correct dimensionality for the store; implementations SHOULD return MemoryError::Embedding on a mismatch.

Source

fn search<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, query: &'life1 [f32], filter: &'life2 VectorFilter, top_k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorMatch>, MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Return the top-top_k most similar vectors to query, applying filter constraints. Results are ordered by descending similarity score.

Source

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

Delete the embedding for id. Returns Ok(()) if the id was not found (idempotent).

Source

fn delete_by_scope<'life0, 'life1, 'async_trait>( &'life0 self, scope: &'life1 Scope, ) -> Pin<Box<dyn Future<Output = Result<u64, MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete all embeddings associated with scope.

Returns the number of entries removed.

Implementors§