Skip to main content

VectorCollection

Trait VectorCollection 

Source
pub trait VectorCollection: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn definition(&self) -> &VectorStoreCollectionDefinition;
    fn ensure_collection_exists<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn collection_exists<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn ensure_collection_deleted<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn upsert<'life0, 'async_trait>(
        &'life0 self,
        records: Vec<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Value>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn get<'life0, 'async_trait>(
        &'life0 self,
        keys: Vec<Value>,
        include_vectors: bool,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Value>>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn delete<'life0, 'async_trait>(
        &'life0 self,
        keys: Vec<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn search<'life0, 'life1, 'async_trait>(
        &'life0 self,
        vector: Vec<f32>,
        options: &'life1 VectorSearchOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorSearchResult>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

One collection’s data plane: create/drop, read/write, and search.

Object-safe, so a caller can hold Box<dyn VectorCollection> and swap providers. Records are serde_json::Value objects keyed by logical field name — see the module docs.

Required Methods§

Source

fn name(&self) -> &str

The collection’s name in the store.

Source

fn definition(&self) -> &VectorStoreCollectionDefinition

The collection’s field definition.

Source

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

Create the collection if it does not exist. Succeeds when it already does.

Source

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

Whether the collection exists.

Source

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

Delete the collection if it exists. Succeeds when it does not.

Source

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

Insert or replace records, returning their keys in input order.

Source

fn get<'life0, 'async_trait>( &'life0 self, keys: Vec<Value>, include_vectors: bool, ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Value>>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetch records by key, in the order the keys were given. A key with no record yields None in its slot rather than shortening the result, so a caller can align the two lists.

Source

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

Delete records by key. Deleting an absent key is not an error.

Source

fn search<'life0, 'life1, 'async_trait>( &'life0 self, vector: Vec<f32>, options: &'life1 VectorSearchOptions, ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorSearchResult>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Search by embedding.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§