Skip to main content

VectorBackend

Trait VectorBackend 

Source
pub trait VectorBackend: Send + Sync {
    // Required methods
    fn search<'life0, 'async_trait>(
        &'life0 self,
        params: VectorSearchParams,
    ) -> Pin<Box<dyn Future<Output = Result<VectorSearchResults>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn name(&self) -> &str;
    fn document_count(&self) -> Result<usize>;

    // Provided method
    fn is_ready(&self) -> bool { ... }
}
Expand description

Abstract vector search backend trait.

Implementations provide different vector search strategies:

  • LancedbBackend: Approximate nearest neighbor with LanceDB
  • SimpleVectorBackend: Brute-force cosine similarity (fallback)

§Async

The search method is async to support I/O-bound operations (embedding generation, index access) without blocking.

Required Methods§

Source

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

Execute a vector similarity search.

The query string is embedded using the backend’s embedding provider, then compared against indexed vectors. Results are ordered by similarity score (highest first).

Source

fn name(&self) -> &str

Get the backend name for diagnostics.

Source

fn document_count(&self) -> Result<usize>

Get the number of indexed documents.

Provided Methods§

Source

fn is_ready(&self) -> bool

Check if the backend is ready to handle queries.

Implementors§