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 LanceDBSimpleVectorBackend: 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§
Sourcefn 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 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).
Sourcefn document_count(&self) -> Result<usize>
fn document_count(&self) -> Result<usize>
Get the number of indexed documents.