VectorIndexProvider

Trait VectorIndexProvider 

Source
pub trait VectorIndexProvider: Send + Sync {
    // Required methods
    fn search(
        &self,
        index_name: &str,
        query: &Embedding,
        k: usize,
        ef_search: Option<usize>,
    ) -> Result<Vec<SearchResult>, VectorError>;
    fn has_index(&self, index_name: &str) -> bool;
    fn dimension(&self, index_name: &str) -> Option<usize>;
}
Expand description

A trait for providing access to vector indexes.

This trait allows type-erased access to vector indexes for query execution. Implementations can wrap HNSW indexes or other vector index types.

Required Methods§

Source

fn search( &self, index_name: &str, query: &Embedding, k: usize, ef_search: Option<usize>, ) -> Result<Vec<SearchResult>, VectorError>

Search for nearest neighbors in the specified index.

§Arguments
  • index_name - The name of the vector index to search
  • query - The query embedding
  • k - Number of nearest neighbors to return
  • ef_search - Optional HNSW ef_search parameter
§Returns

A vector of search results sorted by distance, or an error if the index is not found or the search fails.

Source

fn has_index(&self, index_name: &str) -> bool

Check if a vector index exists.

Source

fn dimension(&self, index_name: &str) -> Option<usize>

Get the dimension of vectors in the specified index.

Implementors§