pub trait VectorStore: Send + Sync {
// Required methods
fn add_texts<'life0, 'async_trait>(
&'life0 mut self,
texts: Vec<String>,
metadata: Option<Vec<HashMap<String, Value>>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn add_vectors<'life0, 'async_trait>(
&'life0 mut self,
vectors: Vec<Vec<f32>>,
texts: Vec<String>,
metadata: Option<Vec<HashMap<String, Value>>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn similarity_search_by_vector<'life0, 'async_trait>(
&'life0 self,
query_vector: Vec<f32>,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn delete<'life0, 'async_trait>(
&'life0 mut self,
ids: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn len(&self) -> usize;
// Provided methods
fn similarity_search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
filter: &'life2 Filter,
) -> 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 is_empty(&self) -> bool { ... }
}Expand description
A vector store: holds documents + their embeddings, supports add + similarity search + delete.
Required Methods§
Sourcefn add_texts<'life0, 'async_trait>(
&'life0 mut self,
texts: Vec<String>,
metadata: Option<Vec<HashMap<String, Value>>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_texts<'life0, 'async_trait>(
&'life0 mut self,
texts: Vec<String>,
metadata: Option<Vec<HashMap<String, Value>>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add documents (text + optional metadata). The store is responsible for embedding them. Returns the IDs assigned.
Sourcefn add_vectors<'life0, 'async_trait>(
&'life0 mut self,
vectors: Vec<Vec<f32>>,
texts: Vec<String>,
metadata: Option<Vec<HashMap<String, Value>>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_vectors<'life0, 'async_trait>(
&'life0 mut self,
vectors: Vec<Vec<f32>>,
texts: Vec<String>,
metadata: Option<Vec<HashMap<String, Value>>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add pre-embedded vectors directly. Useful when the caller has already paid the embedding cost.
Sourcefn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Similarity search: embed the query, return top-k matches.
Sourcefn similarity_search_by_vector<'life0, 'async_trait>(
&'life0 self,
query_vector: Vec<f32>,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn similarity_search_by_vector<'life0, 'async_trait>(
&'life0 self,
query_vector: Vec<f32>,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Similarity search by pre-computed query vector.
Provided Methods§
Sourcefn similarity_search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
filter: &'life2 Filter,
) -> 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 similarity_search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
filter: &'life2 Filter,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Similarity search with a metadata filter.
Default impl runs similarity_search with k * 4 candidates and
post-filters in the caller. Stores with native filter support
(Qdrant, Pinecone, …) override for efficiency.