InvertedIndex

Struct InvertedIndex 

Source
pub struct InvertedIndex<E: StorageEngine> { /* private fields */ }
Expand description

Inverted index for sparse vector similarity search.

Implementations§

Source§

impl<E: StorageEngine> InvertedIndex<E>

Source

pub const fn new(engine: E) -> Self

Create a new inverted index with the given storage engine.

Source

pub fn engine(&self) -> &E

Get a reference to the storage engine.

Source

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 name
  • vector_name - Vector name within the collection
  • point_id - Point ID
  • vector - Sparse vector as (token_id, weight) pairs (must be sorted)
Source

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.

Source

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).

Source

pub fn delete_collection(&self, collection: &str) -> Result<(), VectorError>

Delete all index data for a collection.

Source

pub fn delete_vector( &self, collection: &str, vector_name: &str, ) -> Result<(), VectorError>

Delete all index data for a specific vector in a collection.

Source

pub fn get_meta( &self, collection: &str, vector_name: &str, ) -> Result<InvertedIndexMeta, VectorError>

Get index metadata.

Source

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.

Source

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 name
  • vector_name - Vector name
  • query - Query vector as (token_id, weight) pairs
  • top_k - Number of results to return
  • scoring - Scoring function to use
Source

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 name
  • vector_name - Vector name
  • query - Query vector as (token_id, weight) pairs
  • top_k - Number of results to return
Source

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.

Auto Trait Implementations§

§

impl<E> Freeze for InvertedIndex<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for InvertedIndex<E>
where E: RefUnwindSafe,

§

impl<E> Send for InvertedIndex<E>

§

impl<E> Sync for InvertedIndex<E>

§

impl<E> Unpin for InvertedIndex<E>
where E: Unpin,

§

impl<E> UnwindSafe for InvertedIndex<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more