Skip to main content

VectorStore

Trait VectorStore 

Source
pub trait VectorStore: StorageBackend {
Show 13 methods // Required methods fn ensure_collection<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'life1 str, dimension: 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, collection: &'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<String>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn collection_exists<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn upsert<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'life1 str, document: VectorDocument, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn upsert_batch<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'life1 str, documents: Vec<VectorDocument>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection: &'life1 str, id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Option<VectorDocument>>> + 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, id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn delete_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection: &'life1 str, ids: &'life2 [String], ) -> Pin<Box<dyn Future<Output = Result<()>> + 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, query_embedding: &'life2 [f32], limit: usize, filter: Option<VectorFilter>, ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorSearchResult>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn count<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn collection_info<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<CollectionInfo>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided method fn search_with_threshold<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection: &'life1 str, query_embedding: &'life2 [f32], limit: usize, min_score: f32, filter: Option<VectorFilter>, ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorSearchResult>>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... }
}
Expand description

VectorStore trait - semantic memory

Provides vector similarity search for RAG and long-term memory.

Required Methods§

Source

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

Create a collection if it doesn’t exist

§Arguments
  • collection - Collection name
  • dimension - Vector dimension (must match embeddings)
Source

fn delete_collection<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'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 documents

Source

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

List all collections

Source

fn collection_exists<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'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 upsert<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'life1 str, document: VectorDocument, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Upsert a document (insert or update)

If a document with the same ID exists, it is replaced.

Source

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

Upsert multiple documents atomically

Source

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

Get a document by ID

Source

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

Delete a document by ID

Source

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

Delete multiple documents by ID

Source

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

Search for similar documents

§Arguments
  • collection - Collection to search
  • query_embedding - Query vector (must match collection dimension)
  • limit - Maximum number of results
  • filter - Optional metadata filter
§Returns

Results ordered by similarity (highest score first)

Source

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

Count documents in a collection

Source

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

Get collection info (dimension, count, etc.)

Provided Methods§

Source

fn search_with_threshold<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection: &'life1 str, query_embedding: &'life2 [f32], limit: usize, min_score: f32, filter: Option<VectorFilter>, ) -> Pin<Box<dyn Future<Output = Result<Vec<VectorSearchResult>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Search with score threshold

Only returns results with score >= min_score.

Implementors§