pub trait VectorStore:
Send
+ Sync
+ Debug {
// Required methods
fn upsert(
&self,
chunks: Vec<StoredChunk>,
) -> BoxFuture<'_, Result<(), RagError>>;
fn delete_document<'a>(
&'a self,
dataset_id: &'a str,
document_id: &'a str,
) -> BoxFuture<'a, Result<usize, RagError>>;
fn delete_dataset<'a>(
&'a self,
dataset_id: &'a str,
) -> BoxFuture<'a, Result<usize, RagError>>;
fn document_chunks<'a>(
&'a self,
dataset_id: &'a str,
document_id: &'a str,
) -> BoxFuture<'a, Result<Vec<StoredChunk>, RagError>>;
fn delete_chunks<'a>(
&'a self,
dataset_id: &'a str,
ids: &'a [String],
) -> BoxFuture<'a, Result<usize, RagError>>;
fn search<'a>(
&'a self,
query: VectorQuery<'a>,
) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>;
// Provided methods
fn supports_keyword(&self) -> bool { ... }
fn keyword_search<'a>(
&'a self,
query: KeywordQuery<'a>,
) -> BoxFuture<'a, Result<Vec<Hit>, RagError>> { ... }
fn contains_hash<'a>(
&'a self,
dataset_id: &'a str,
content_hash: &'a str,
) -> BoxFuture<'a, Result<bool, RagError>> { ... }
}Expand description
Stores chunks with vectors and answers similarity queries.
Required Methods§
Sourcefn upsert(
&self,
chunks: Vec<StoredChunk>,
) -> BoxFuture<'_, Result<(), RagError>>
fn upsert( &self, chunks: Vec<StoredChunk>, ) -> BoxFuture<'_, Result<(), RagError>>
Insert or replace chunks (by id).
Sourcefn delete_document<'a>(
&'a self,
dataset_id: &'a str,
document_id: &'a str,
) -> BoxFuture<'a, Result<usize, RagError>>
fn delete_document<'a>( &'a self, dataset_id: &'a str, document_id: &'a str, ) -> BoxFuture<'a, Result<usize, RagError>>
Remove every chunk of a document. Returns the number removed when known.
Sourcefn delete_dataset<'a>(
&'a self,
dataset_id: &'a str,
) -> BoxFuture<'a, Result<usize, RagError>>
fn delete_dataset<'a>( &'a self, dataset_id: &'a str, ) -> BoxFuture<'a, Result<usize, RagError>>
Remove every chunk of a dataset.
Sourcefn document_chunks<'a>(
&'a self,
dataset_id: &'a str,
document_id: &'a str,
) -> BoxFuture<'a, Result<Vec<StoredChunk>, RagError>>
fn document_chunks<'a>( &'a self, dataset_id: &'a str, document_id: &'a str, ) -> BoxFuture<'a, Result<Vec<StoredChunk>, RagError>>
Every chunk of one document, vectors included. The ingestor uses this to re-ingest a document without re-embedding unchanged chunks and to find the chunks a new version no longer contains.
Provided Methods§
Sourcefn supports_keyword(&self) -> bool
fn supports_keyword(&self) -> bool
Whether VectorStore::keyword_search is implemented.
Sourcefn keyword_search<'a>(
&'a self,
query: KeywordQuery<'a>,
) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>
fn keyword_search<'a>( &'a self, query: KeywordQuery<'a>, ) -> BoxFuture<'a, Result<Vec<Hit>, RagError>>
Keyword (BM25) search, best first. Stores without a keyword index return nothing.
Sourcefn contains_hash<'a>(
&'a self,
dataset_id: &'a str,
content_hash: &'a str,
) -> BoxFuture<'a, Result<bool, RagError>>
fn contains_hash<'a>( &'a self, dataset_id: &'a str, content_hash: &'a str, ) -> BoxFuture<'a, Result<bool, RagError>>
Whether a chunk with this content hash already exists in the dataset.
Stores that cannot answer cheaply return false. The built-in crate::Ingestor
does not use this (it de-duplicates per document via VectorStore::document_chunks).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".