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§
Sourcefn search(
&self,
index_name: &str,
query: &Embedding,
k: usize,
ef_search: Option<usize>,
) -> Result<Vec<SearchResult>, VectorError>
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 searchquery- The query embeddingk- Number of nearest neighbors to returnef_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.