pub struct ChunkedVectorStore { /* private fields */ }Expand description
Chunked Vector Store
Implementations§
Source§impl ChunkedVectorStore
impl ChunkedVectorStore
Sourcepub fn new(
document_store: Arc<InMemoryChunkedDocumentStore>,
vector_size: usize,
) -> ChunkedVectorStore
pub fn new( document_store: Arc<InMemoryChunkedDocumentStore>, vector_size: usize, ) -> ChunkedVectorStore
Creates a new ChunkedVectorStore
Sourcepub async fn add_chunk_vector(
&self,
chunk_id: impl Into<String>,
embedding: Vec<f32>,
) -> Result<(), VectorStoreError>
pub async fn add_chunk_vector( &self, chunk_id: impl Into<String>, embedding: Vec<f32>, ) -> Result<(), VectorStoreError>
Adds a chunk vector (chunk_id + embedding)
Sourcepub async fn add_chunk_vectors(
&self,
chunk_ids: Vec<String>,
embeddings: Vec<Vec<f32>>,
) -> Result<(), VectorStoreError>
pub async fn add_chunk_vectors( &self, chunk_ids: Vec<String>, embeddings: Vec<Vec<f32>>, ) -> Result<(), VectorStoreError>
Adds chunk vectors in bulk
Sourcepub async fn add_parent_document(
&self,
document: Document,
chunk_size: usize,
embeddings_fn: impl Fn(&str) -> Vec<f32>,
) -> Result<(String, Vec<String>), VectorStoreError>
pub async fn add_parent_document( &self, document: Document, chunk_size: usize, embeddings_fn: impl Fn(&str) -> Vec<f32>, ) -> Result<(String, Vec<String>), VectorStoreError>
Adds from a Parent document (auto-split + vectorized)
Sourcepub async fn get_embedding(
&self,
chunk_id: &str,
) -> Result<Option<Vec<f32>>, VectorStoreError>
pub async fn get_embedding( &self, chunk_id: &str, ) -> Result<Option<Vec<f32>>, VectorStoreError>
Gets the vector for a chunk_id (M4: O(1) HashMap lookup)
Sourcepub async fn vector_count(&self) -> usize
pub async fn vector_count(&self) -> usize
Gets the number of stored vectors
Trait Implementations§
Source§impl VectorStore for ChunkedVectorStore
impl VectorStore for ChunkedVectorStore
Source§fn similarity_search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
filter: Option<&'life2 MetadataFilter>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn similarity_search_with_filter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
filter: Option<&'life2 MetadataFilter>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
ChunkedVectorStore: 'async_trait,
S3: chunked-store metadata filtering.
The vector index carries no metadata, so filtering requires fetching documents from the document store by chunk_id. The semantics are “score everything → scan descending, filtering each item by metadata → stop once k items are collected”, guaranteeing the top-k by similarity after filtering (rather than truncating first and filtering later).
Source§fn add_documents<'life0, 'async_trait>(
&'life0 self,
documents: Vec<Document>,
embeddings: Vec<Vec<f32>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn add_documents<'life0, 'async_trait>(
&'life0 self,
documents: Vec<Document>,
embeddings: Vec<Vec<f32>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
Adds documents. Read more
Source§fn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn similarity_search<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Searches similar documents. Read more
Source§fn similarity_search_with_min_score<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
min_score: Option<f32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn similarity_search_with_min_score<'life0, 'life1, 'async_trait>(
&'life0 self,
query_embedding: &'life1 [f32],
k: usize,
min_score: Option<f32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Similarity search with a minimum score threshold. Read more
Source§fn get_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn get_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Gets document by ID.
Source§fn get_embedding<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<f32>>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn get_embedding<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<f32>>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Gets document embedding by ID.
Source§fn delete_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn delete_document<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ChunkedVectorStore: 'async_trait,
Deletes document.
Source§fn count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
Returns document count.
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
ChunkedVectorStore: 'async_trait,
Clears store.
Source§fn embed_query(&self) -> Option<&dyn Embeddings>
fn embed_query(&self) -> Option<&dyn Embeddings>
Returns this vector store’s built-in text embedder, if any. Read more
Source§fn similarity_search_text<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn similarity_search_text<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
k: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Text similarity search: vectorizes
query with the embedder returned by
embed_query, then searches. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ChunkedVectorStore
impl !UnwindSafe for ChunkedVectorStore
impl Freeze for ChunkedVectorStore
impl Send for ChunkedVectorStore
impl Sync for ChunkedVectorStore
impl Unpin for ChunkedVectorStore
impl UnsafeUnpin for ChunkedVectorStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more