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 scroll_all_with_point_ids(
&self,
collection: &str,
key_field: &str,
) -> Pin<Box<dyn Future<Output = Result<ScrollWithIdsResult, VectorStoreError>> + Send + '_>>;
fn health_check(
&self,
) -> Pin<Box<dyn Future<Output = Result<bool, VectorStoreError>> + Send + '_>>;
// Provided methods
fn create_keyword_indexes(
&self,
_collection: &str,
_fields: &[&str],
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>> { ... }
fn get_points(
&self,
_collection: &str,
_ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<VectorPoint>, 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
| Type | Notes |
|---|---|
crate::embedding_store::EmbeddingStore | Qdrant-backed; production default. |
crate::db_vector_store::DbVectorStore | SQLite BLOB; offline / CI use. |
crate::in_memory_store::InMemoryVectorStore | Fully in-process; unit tests. |
Required Methods§
Sourcefn ensure_collection(
&self,
collection: &str,
vector_size: u64,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>
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.
Sourcefn collection_exists(
&self,
collection: &str,
) -> Pin<Box<dyn Future<Output = Result<bool, VectorStoreError>> + Send + '_>>
fn collection_exists( &self, collection: &str, ) -> Pin<Box<dyn Future<Output = Result<bool, VectorStoreError>> + Send + '_>>
Returns true if collection exists in the backend.
Sourcefn delete_collection(
&self,
collection: &str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>
fn delete_collection( &self, collection: &str, ) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>
Delete a collection and all its points.
Sourcefn upsert(
&self,
collection: &str,
points: Vec<VectorPoint>,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>
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.
Sourcefn search(
&self,
collection: &str,
vector: Vec<f32>,
limit: u64,
filter: Option<VectorFilter>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ScoredVectorPoint>, 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 + '_>>
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.
Sourcefn delete_by_ids(
&self,
collection: &str,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>
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.
Sourcefn scroll_all(
&self,
collection: &str,
key_field: &str,
) -> Pin<Box<dyn Future<Output = Result<ScrollResult, VectorStoreError>> + Send + '_>>
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.
Sourcefn scroll_all_with_point_ids(
&self,
collection: &str,
key_field: &str,
) -> Pin<Box<dyn Future<Output = Result<ScrollWithIdsResult, VectorStoreError>> + Send + '_>>
fn scroll_all_with_point_ids( &self, collection: &str, key_field: &str, ) -> Pin<Box<dyn Future<Output = Result<ScrollWithIdsResult, VectorStoreError>> + Send + '_>>
Scroll all points in collection, returning (point_id, string_payload_fields) pairs.
Only points whose payload contains key_field as a string value are included.
Unlike Self::scroll_all, the Qdrant point ID is preserved as the first tuple element
rather than being used as the map key — this is required when consumers need to delete
points by their IDs (e.g. stale-embedding cleanup).
§Errors
Returns an error if the underlying scroll operation fails.
Sourcefn health_check(
&self,
) -> Pin<Box<dyn Future<Output = Result<bool, VectorStoreError>> + Send + '_>>
fn health_check( &self, ) -> Pin<Box<dyn Future<Output = Result<bool, VectorStoreError>> + Send + '_>>
Return true if the backend is reachable and operational.
Provided Methods§
Sourcefn create_keyword_indexes(
&self,
_collection: &str,
_fields: &[&str],
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + '_>>
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).
Sourcefn get_points(
&self,
_collection: &str,
_ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<VectorPoint>, VectorStoreError>> + Send + '_>>
fn get_points( &self, _collection: &str, _ids: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorPoint>, VectorStoreError>> + Send + '_>>
Batched vector + payload retrieval by point IDs.
Returns one VectorPoint per matched id (missing ids are silently dropped).
Backends that cannot return vectors return Err(VectorStoreError::Unsupported).
§Errors
Returns VectorStoreError::Unsupported when the backend does not support
direct point retrieval with vectors (e.g. DbVectorStore, InMemoryVectorStore
unless overridden in tests).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".