pub struct InvertedIndex<E: StorageEngine> { /* private fields */ }Expand description
Inverted index for sparse vector similarity search.
Implementations§
Source§impl<E: StorageEngine> InvertedIndex<E>
impl<E: StorageEngine> InvertedIndex<E>
Sourcepub fn insert(
&self,
collection: &str,
vector_name: &str,
point_id: PointId,
vector: &[(u32, f32)],
) -> Result<(), VectorError>
pub fn insert( &self, collection: &str, vector_name: &str, point_id: PointId, vector: &[(u32, f32)], ) -> Result<(), VectorError>
Insert a sparse vector into the index.
§Arguments
collection- Collection namevector_name- Vector name within the collectionpoint_id- Point IDvector- Sparse vector as (token_id, weight) pairs (must be sorted)
Sourcepub fn delete(
&self,
collection: &str,
vector_name: &str,
point_id: PointId,
) -> Result<bool, VectorError>
pub fn delete( &self, collection: &str, vector_name: &str, point_id: PointId, ) -> Result<bool, VectorError>
Delete a sparse vector from the index.
§Returns
Returns Ok(true) if the vector was deleted, Ok(false) if it wasn’t indexed.
Sourcepub fn update(
&self,
collection: &str,
vector_name: &str,
point_id: PointId,
vector: &[(u32, f32)],
) -> Result<(), VectorError>
pub fn update( &self, collection: &str, vector_name: &str, point_id: PointId, vector: &[(u32, f32)], ) -> Result<(), VectorError>
Update a sparse vector in the index (delete + insert).
Sourcepub fn delete_collection(&self, collection: &str) -> Result<(), VectorError>
pub fn delete_collection(&self, collection: &str) -> Result<(), VectorError>
Delete all index data for a collection.
Sourcepub fn delete_vector(
&self,
collection: &str,
vector_name: &str,
) -> Result<(), VectorError>
pub fn delete_vector( &self, collection: &str, vector_name: &str, ) -> Result<(), VectorError>
Delete all index data for a specific vector in a collection.
Sourcepub fn get_meta(
&self,
collection: &str,
vector_name: &str,
) -> Result<InvertedIndexMeta, VectorError>
pub fn get_meta( &self, collection: &str, vector_name: &str, ) -> Result<InvertedIndexMeta, VectorError>
Get index metadata.
Sourcepub fn get_posting_list(
&self,
collection: &str,
vector_name: &str,
token_id: u32,
) -> Result<Option<PostingList>, VectorError>
pub fn get_posting_list( &self, collection: &str, vector_name: &str, token_id: u32, ) -> Result<Option<PostingList>, VectorError>
Get a posting list for a specific token.
Sourcepub fn search_daat(
&self,
collection: &str,
vector_name: &str,
query: &[(u32, f32)],
top_k: usize,
scoring: ScoringFunction,
) -> Result<Vec<SearchResult>, VectorError>
pub fn search_daat( &self, collection: &str, vector_name: &str, query: &[(u32, f32)], top_k: usize, scoring: ScoringFunction, ) -> Result<Vec<SearchResult>, VectorError>
Search using DAAT (Document-at-a-time) algorithm.
This is exact scoring that traverses all posting lists to compute the full similarity score for each candidate document.
§Arguments
collection- Collection namevector_name- Vector namequery- Query vector as (token_id, weight) pairstop_k- Number of results to returnscoring- Scoring function to use
Sourcepub fn search_wand(
&self,
collection: &str,
vector_name: &str,
query: &[(u32, f32)],
top_k: usize,
) -> Result<Vec<SearchResult>, VectorError>
pub fn search_wand( &self, collection: &str, vector_name: &str, query: &[(u32, f32)], top_k: usize, ) -> Result<Vec<SearchResult>, VectorError>
Search using WAND (Weak AND) algorithm.
This is an optimized top-k search that uses upper bound scores to skip documents that cannot make it into the result set.
§Arguments
collection- Collection namevector_name- Vector namequery- Query vector as (token_id, weight) pairstop_k- Number of results to return
Sourcepub fn search_maxscore(
&self,
collection: &str,
vector_name: &str,
query: &[(u32, f32)],
top_k: usize,
) -> Result<Vec<SearchResult>, VectorError>
pub fn search_maxscore( &self, collection: &str, vector_name: &str, query: &[(u32, f32)], top_k: usize, ) -> Result<Vec<SearchResult>, VectorError>
Search using MaxScore algorithm (optimized WAND variant).
Similar to WAND but more aggressive at skipping low-scoring documents.