pub trait VectorStore: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn dimension(&self) -> usize;
fn metric(&self) -> DistanceMetric;
fn upsert<'life0, 'async_trait>(
&'life0 self,
records: Vec<VectorRecord>,
) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
vector: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = VectorResult<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
vector: &'life1 [f32],
k: usize,
filter: &'life2 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = VectorResult<Vec<SearchResult>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = VectorResult<Option<VectorRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ids: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = VectorResult<Vec<VectorRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ids: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = VectorResult<usize>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Abstract interface for vector storage and search.
Implementations of this trait provide vector storage and similarity search capabilities, allowing Phago to use different vector database backends.
Required Methods§
Sourcefn metric(&self) -> DistanceMetric
fn metric(&self) -> DistanceMetric
Get the distance metric.
Sourcefn upsert<'life0, 'async_trait>(
&'life0 self,
records: Vec<VectorRecord>,
) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn upsert<'life0, 'async_trait>(
&'life0 self,
records: Vec<VectorRecord>,
) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Insert or update records in the store.
If a record with the same ID exists, it will be updated.
Sourcefn search<'life0, 'life1, 'async_trait>(
&'life0 self,
vector: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = VectorResult<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
vector: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = VectorResult<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Search for similar vectors.
Returns the top k most similar records.
Sourcefn search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
vector: &'life1 [f32],
k: usize,
filter: &'life2 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = VectorResult<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
vector: &'life1 [f32],
k: usize,
filter: &'life2 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = VectorResult<Vec<SearchResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Search with metadata filter.
Only returns records matching the filter criteria.
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = VectorResult<Option<VectorRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = VectorResult<Option<VectorRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a record by ID.
Sourcefn get_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ids: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = VectorResult<Vec<VectorRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ids: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = VectorResult<Vec<VectorRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get multiple records by ID.
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a record by ID.
Sourcefn delete_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ids: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = VectorResult<()>> + 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,
ids: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = VectorResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete multiple records by ID.