Skip to main content

VectorStore

Trait VectorStore 

Source
pub trait VectorStore: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn dimension(&self) -> usize;
    fn metric(&self) -> DistanceMetric;
    fn upsert<'life0, 'async_trait>(
        &'life0 self,
        records: Vec<VectorRecord>,
    ) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn search<'life0, 'life1, 'async_trait>(
        &'life0 self,
        vector: &'life1 [f32],
        k: usize,
    ) -> Pin<Box<dyn Future<Output = VectorResult<Vec<SearchResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        vector: &'life1 [f32],
        k: usize,
        filter: &'life2 HashMap<String, Value>,
    ) -> Pin<Box<dyn Future<Output = VectorResult<Vec<SearchResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = VectorResult<Option<VectorRecord>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_batch<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ids: &'life1 [&'life2 str],
    ) -> Pin<Box<dyn Future<Output = VectorResult<Vec<VectorRecord>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_batch<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ids: &'life1 [&'life2 str],
    ) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn count<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = VectorResult<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Abstract interface for vector storage and search.

Implementations of this trait provide vector storage and similarity search capabilities, allowing Phago to use different vector database backends.

Required Methods§

Source

fn name(&self) -> &str

Get the name of this backend.

Source

fn dimension(&self) -> usize

Get the vector dimension.

Source

fn metric(&self) -> DistanceMetric

Get the distance metric.

Source

fn upsert<'life0, 'async_trait>( &'life0 self, records: Vec<VectorRecord>, ) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Insert or update records in the store.

If a record with the same ID exists, it will be updated.

Source

fn search<'life0, 'life1, 'async_trait>( &'life0 self, vector: &'life1 [f32], k: usize, ) -> Pin<Box<dyn Future<Output = VectorResult<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Search for similar vectors.

Returns the top k most similar records.

Source

fn search_with_filter<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, vector: &'life1 [f32], k: usize, filter: &'life2 HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = VectorResult<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Search with metadata filter.

Only returns records matching the filter criteria.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = VectorResult<Option<VectorRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a record by ID.

Source

fn get_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ids: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = VectorResult<Vec<VectorRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get multiple records by ID.

Source

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

Delete a record by ID.

Source

fn delete_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ids: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete multiple records by ID.

Source

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

Get the total number of records in the store.

Source

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

Clear all records from the store.

Implementors§