Trait VectorStorage

Source
pub trait VectorStorage: Send + Sync {
    type Config: Send + Sync;

    // Required methods
    fn create_index<'life0, 'async_trait>(
        &'life0 self,
        config: IndexConfig,
    ) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn list_indexes<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, VectorError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn describe_index<'life0, 'life1, 'async_trait>(
        &'life0 self,
        index_name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<IndexInfo, VectorError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn delete_index<'life0, 'life1, 'async_trait>(
        &'life0 self,
        index_name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn upsert_documents<'life0, 'life1, 'async_trait>(
        &'life0 self,
        index_name: &'life1 str,
        documents: Vec<Document>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, VectorError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn search<'life0, 'async_trait>(
        &'life0 self,
        request: SearchRequest,
    ) -> Pin<Box<dyn Future<Output = Result<SearchResponse, VectorError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn update_document<'life0, 'life1, 'async_trait>(
        &'life0 self,
        index_name: &'life1 str,
        document: Document,
    ) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn delete_documents<'life0, 'life1, 'async_trait>(
        &'life0 self,
        index_name: &'life1 str,
        ids: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn get_documents<'life0, 'life1, 'async_trait>(
        &'life0 self,
        index_name: &'life1 str,
        ids: Vec<String>,
        include_vectors: bool,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, VectorError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn backend_info(&self) -> BackendInfo;
}
Expand description

Core trait for vector storage backends

This trait defines the interface that all vector storage implementations must provide. It’s designed to be storage-agnostic and support various backends like in-memory, SQLite, Qdrant, MongoDB, etc.

Required Associated Types§

Source

type Config: Send + Sync

Storage-specific configuration type

Required Methods§

Source

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

Create a new vector index

Source

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

List all available indexes

Source

fn describe_index<'life0, 'life1, 'async_trait>( &'life0 self, index_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<IndexInfo, VectorError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Get information about a specific index

Source

fn delete_index<'life0, 'life1, 'async_trait>( &'life0 self, index_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Delete an index and all its vectors

Source

fn upsert_documents<'life0, 'life1, 'async_trait>( &'life0 self, index_name: &'life1 str, documents: Vec<Document>, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, VectorError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Insert or update documents in the index

Source

fn search<'life0, 'async_trait>( &'life0 self, request: SearchRequest, ) -> Pin<Box<dyn Future<Output = Result<SearchResponse, VectorError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Search for similar vectors

Source

fn update_document<'life0, 'life1, 'async_trait>( &'life0 self, index_name: &'life1 str, document: Document, ) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Update a specific document

Source

fn delete_documents<'life0, 'life1, 'async_trait>( &'life0 self, index_name: &'life1 str, ids: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<(), VectorError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Delete documents by IDs

Source

fn get_documents<'life0, 'life1, 'async_trait>( &'life0 self, index_name: &'life1 str, ids: Vec<String>, include_vectors: bool, ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, VectorError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Get documents by IDs

Source

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

Check if the storage backend is healthy

Source

fn backend_info(&self) -> BackendInfo

Get storage backend information

Implementors§