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
| 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 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.