Skip to main content

SparseIndex

Trait SparseIndex 

Source
pub trait SparseIndex: Send + Sync {
    // Required methods
    fn add(&mut self, chunk: &Chunk);
    fn add_batch(&mut self, chunks: &[Chunk]);
    fn search(&self, query: &str, k: usize) -> Vec<(ChunkId, f32)>;
    fn remove(&mut self, chunk_id: ChunkId);
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Sparse index trait for lexical retrieval

Required Methods§

Source

fn add(&mut self, chunk: &Chunk)

Index a chunk

Source

fn add_batch(&mut self, chunks: &[Chunk])

Index multiple chunks

Source

fn search(&self, query: &str, k: usize) -> Vec<(ChunkId, f32)>

Search for matching chunks

Source

fn remove(&mut self, chunk_id: ChunkId)

Remove a chunk from the index

Source

fn len(&self) -> usize

Get the number of indexed documents

Provided Methods§

Source

fn is_empty(&self) -> bool

Check if the index is empty

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§