Skip to main content

VectorStore

Trait VectorStore 

Source
pub trait VectorStore: Send + Sync {
    // Required methods
    fn migrate<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn upsert_document<'life0, 'life1, 'async_trait>(
        &'life0 self,
        doc: &'life1 Document,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn find_document_by_hash<'life0, 'life1, 'async_trait>(
        &'life0 self,
        hash: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn insert_chunks<'life0, 'life1, 'async_trait>(
        &'life0 self,
        chunks: &'life1 [Chunk],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn vector_search<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 [f32],
        k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Scored>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn all_chunks<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Chunk>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn count_chunks<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn count_documents<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list_documents<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete_document<'life0, 'life1, 'async_trait>(
        &'life0 self,
        doc_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_documents_by_source<'life0, 'life1, 'async_trait>(
        &'life0 self,
        source_uri: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A document + chunk store with dense vector search.

Required Methods§

Source

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

Create tables/indexes if they do not exist. Safe to call repeatedly.

Source

fn upsert_document<'life0, 'life1, 'async_trait>( &'life0 self, doc: &'life1 Document, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Insert or replace a document row (keyed by id).

Source

fn find_document_by_hash<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Return the id of an existing document with this content hash, if any. Used to skip re-ingesting unchanged documents.

Source

fn insert_chunks<'life0, 'life1, 'async_trait>( &'life0 self, chunks: &'life1 [Chunk], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Bulk-insert chunks (each must carry a populated embedding).

Dense search: the k chunks whose embeddings are most cosine-similar to query. Returned chunks omit their embedding vector to keep payloads small.

Source

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

Every chunk (id, doc_id, ordinal, text, metadata) with embedding == None. Feeds the BM25 keyword index; keep it modest for large corpora.

Source

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

Total number of stored chunks.

Source

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

Total number of stored documents.

Source

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

Every stored document with its metadata (including processing metrics).

Source

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

Delete one document and all of its chunks (used to roll back a failed streaming ingest). Deleting an unknown id is not an error.

Source

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

Delete every document (and chunks) originating from source_uri — stale rows from interrupted runs or previous versions of a changed file.

Source

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

Remove all documents and chunks.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§