VectorStore

Trait VectorStore 

Source
pub trait VectorStore: Send + Sync {
    // Required methods
    fn provider_name(&self) -> &'static str;
    fn create_collection<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        dimensions: usize,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_collection<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_collections<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CollectionInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn collection_exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn collection_stats<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<CollectionStats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn upsert<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        collection: &'life1 str,
        documents: &'life2 [Document],
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn search<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        collection: &'life1 str,
        embedding: &'life2 [f32],
        limit: usize,
        threshold: f32,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        collection: &'life1 str,
        ids: &'life2 [String],
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        collection: &'life1 str,
        id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Document>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn search_with_filters<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        collection: &'life1 str,
        embedding: &'life2 [f32],
        limit: usize,
        threshold: f32,
        _filters: &'life3 [(String, String)],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn count<'life0, 'life1, 'async_trait>(
        &'life0 self,
        collection: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Abstract trait for vector database operations.

This trait defines a common interface for all vector store backends, enabling the application to work with different databases interchangeably.

§Implementors

  • LanceDBStore - Serverless, embedded (default)
  • QdrantVectorStore - High-performance server
  • PgVectorStore - PostgreSQL extension
  • ChromaDBStore - Simple embedding database
  • PineconeStore - Managed cloud service
  • InMemoryVectorStore - Testing only

Required Methods§

Source

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

Get the name of this vector store provider.

Source

fn create_collection<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, dimensions: usize, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a new collection with the specified vector dimensions.

§Arguments
  • name - Name of the collection to create.
  • dimensions - Dimensionality of vectors (e.g., 384 for BGE-small).
§Errors

Returns an error if the collection already exists or creation fails.

Source

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

Delete a collection and all its data.

§Arguments
  • name - Name of the collection to delete.
§Errors

Returns an error if the collection doesn’t exist or deletion fails.

Source

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

List all collections in the vector store.

Source

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

Check if a collection exists.

Source

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

Get statistics about a collection.

Source

fn upsert<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection: &'life1 str, documents: &'life2 [Document], ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Upsert documents with their embeddings into a collection.

Documents are identified by their id field. If a document with the same ID already exists, it will be updated.

§Arguments
  • collection - Name of the collection.
  • documents - Documents to upsert (must have embeddings set).
§Errors

Returns an error if any document is missing an embedding or the upsert operation fails.

Source

fn search<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection: &'life1 str, embedding: &'life2 [f32], limit: usize, threshold: f32, ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Search for similar vectors in a collection.

§Arguments
  • collection - Name of the collection to search.
  • embedding - Query vector to find similar documents.
  • limit - Maximum number of results to return.
  • threshold - Minimum similarity score (0.0 to 1.0).
§Returns

A vector of search results, sorted by similarity score (descending).

Source

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

Delete documents by their IDs.

§Arguments
  • collection - Name of the collection.
  • ids - IDs of documents to delete.
§Returns

Number of documents actually deleted.

Source

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

Get a document by ID.

§Arguments
  • collection - Name of the collection.
  • id - Document ID.
§Returns

The document if found, or None.

Provided Methods§

Source

fn search_with_filters<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, collection: &'life1 str, embedding: &'life2 [f32], limit: usize, threshold: f32, _filters: &'life3 [(String, String)], ) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Search with metadata filters.

§Arguments
  • collection - Name of the collection to search.
  • embedding - Query vector.
  • limit - Maximum number of results.
  • threshold - Minimum similarity score.
  • filters - Metadata filters to apply.
§Default Implementation

Falls back to regular search if not overridden.

Source

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

Count documents in a collection.

Implementors§

Source§

impl VectorStore for AresVectorStore

Available on crate feature ares-vector only.
Source§

impl VectorStore for InMemoryVectorStore