Skip to main content

VectorIndex

Trait VectorIndex 

Source
pub trait VectorIndex: Send + Sync {
    // Required methods
    fn search_by_embedding(
        &self,
        collection: &str,
        embedding: &[f32],
        k: usize,
        min_score: Option<f32>,
    ) -> Result<Vec<VectorSearchResult>, String>;
    fn search_by_text(
        &self,
        collection: &str,
        text: &str,
        k: usize,
        min_score: Option<f32>,
    ) -> Result<Vec<VectorSearchResult>, String>;
    fn stats(&self, collection: &str) -> Option<VectorIndexStats>;
}
Expand description

Trait for vector index implementations

This allows plugging in different vector index backends:

  • HNSW from sochdb-index
  • External vector databases (Pinecone, Milvus, etc.)
  • Simple brute-force for small collections

Required Methods§

Source

fn search_by_embedding( &self, collection: &str, embedding: &[f32], k: usize, min_score: Option<f32>, ) -> Result<Vec<VectorSearchResult>, String>

Search for k nearest neighbors to the query vector

Source

fn search_by_text( &self, collection: &str, text: &str, k: usize, min_score: Option<f32>, ) -> Result<Vec<VectorSearchResult>, String>

Search by text (index handles embedding generation)

Source

fn stats(&self, collection: &str) -> Option<VectorIndexStats>

Get index statistics

Implementors§