Skip to main content

VectorStore

Trait VectorStore 

Source
pub trait VectorStore: Send + Sync {
    // Required methods
    fn ensure_collection(
        &self,
        collection: &str,
        vector_size: u64,
    ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>;
    fn collection_exists(
        &self,
        collection: &str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, VectorStoreError>> + Send + '_>>;
    fn delete_collection(
        &self,
        collection: &str,
    ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>;
    fn upsert(
        &self,
        collection: &str,
        points: Vec<VectorPoint>,
    ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>;
    fn search(
        &self,
        collection: &str,
        vector: Vec<f32>,
        limit: u64,
        filter: Option<VectorFilter>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ScoredVectorPoint>, VectorStoreError>> + Send + '_>>;
    fn delete_by_ids(
        &self,
        collection: &str,
        ids: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>;
    fn scroll_all(
        &self,
        collection: &str,
        key_field: &str,
    ) -> Pin<Box<dyn Future<Output = Result<ScrollResult, VectorStoreError>> + Send + '_>>;
    fn health_check(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<bool, VectorStoreError>> + Send + '_>>;

    // Provided method
    fn create_keyword_indexes(
        &self,
        _collection: &str,
        _fields: &[&str],
    ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>> { ... }
}
Expand description

Abstraction over a vector database backend.

Implementations must be Send + Sync so they can be wrapped in Arc and shared across async tasks. All methods return boxed futures via BoxFuture to remain object-safe.

§Implementations

TypeNotes
crate::embedding_store::EmbeddingStoreQdrant-backed; production default.
crate::db_vector_store::DbVectorStoreSQLite BLOB; offline / CI use.
crate::in_memory_store::InMemoryVectorStoreFully in-process; unit tests.

Required Methods§

Source

fn ensure_collection( &self, collection: &str, vector_size: u64, ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>

Create a collection with cosine-distance vectors of vector_size dimensions.

Idempotent — no error if the collection already exists with the same dimension.

Source

fn collection_exists( &self, collection: &str, ) -> Pin<Box<dyn Future<Output = Result<bool, VectorStoreError>> + Send + '_>>

Returns true if collection exists in the backend.

Source

fn delete_collection( &self, collection: &str, ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>

Delete a collection and all its points.

Source

fn upsert( &self, collection: &str, points: Vec<VectorPoint>, ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>

Upsert points into collection.

Points with existing IDs are overwritten; new IDs are inserted.

Source

fn search( &self, collection: &str, vector: Vec<f32>, limit: u64, filter: Option<VectorFilter>, ) -> Pin<Box<dyn Future<Output = Result<Vec<ScoredVectorPoint>, VectorStoreError>> + Send + '_>>

Search collection for the limit nearest neighbours of vector.

Returns results in descending similarity order. An optional VectorFilter restricts the search space to points matching the payload conditions.

Source

fn delete_by_ids( &self, collection: &str, ids: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>

Delete specific points from collection by their string IDs.

Source

fn scroll_all( &self, collection: &str, key_field: &str, ) -> Pin<Box<dyn Future<Output = Result<ScrollResult, VectorStoreError>> + Send + '_>>

Scroll (paginate) all points in collection and return a map of point_id → { key_field → value } payload entries.

Source

fn health_check( &self, ) -> Pin<Box<dyn Future<Output = Result<bool, VectorStoreError>> + Send + '_>>

Return true if the backend is reachable and operational.

Provided Methods§

Source

fn create_keyword_indexes( &self, _collection: &str, _fields: &[&str], ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>

Create keyword payload indexes for the given field names.

Default implementation is a no-op (for non-Qdrant backends).

Implementors§