Skip to main content

VectorStore

Trait VectorStore 

Source
pub trait VectorStore: Send + Sync {
    // Required methods
    async fn add(&self, document: Document) -> Result<()>;
    async fn add_batch(&self, documents: Vec<Document>) -> Result<()>;
    async fn search(
        &self,
        query: &[f32],
        top_k: usize,
    ) -> Result<Vec<Similarity>>;
    async fn search_with_filter(
        &self,
        query: &[f32],
        top_k: usize,
        filter: &MetadataFilter,
    ) -> Result<Vec<Similarity>>;
    async fn search_batch(
        &self,
        queries: &[Vec<f32>],
        top_k: usize,
    ) -> Result<Vec<Vec<Similarity>>>;
    async fn get(&self, id: &str) -> Result<Option<Document>>;
    async fn delete(&self, id: &str) -> Result<bool>;
    async fn delete_batch(&self, ids: Vec<String>) -> Result<usize>;
    async fn clear(&self) -> Result<()>;
    async fn list(&self, limit: usize, offset: usize) -> Result<Vec<Document>>;
    async fn count(&self) -> Result<usize>;
    fn metric(&self) -> DistanceMetric;
}

Required Methods§

Source

async fn add(&self, document: Document) -> Result<()>

Source

async fn add_batch(&self, documents: Vec<Document>) -> Result<()>

Source

async fn search(&self, query: &[f32], top_k: usize) -> Result<Vec<Similarity>>

Source

async fn search_with_filter( &self, query: &[f32], top_k: usize, filter: &MetadataFilter, ) -> Result<Vec<Similarity>>

Source

async fn search_batch( &self, queries: &[Vec<f32>], top_k: usize, ) -> Result<Vec<Vec<Similarity>>>

Source

async fn get(&self, id: &str) -> Result<Option<Document>>

Source

async fn delete(&self, id: &str) -> Result<bool>

Source

async fn delete_batch(&self, ids: Vec<String>) -> Result<usize>

Source

async fn clear(&self) -> Result<()>

Source

async fn list(&self, limit: usize, offset: usize) -> Result<Vec<Document>>

Source

async fn count(&self) -> Result<usize>

Source

fn metric(&self) -> DistanceMetric

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§