Skip to main content

VectorIndex

Trait VectorIndex 

Source
pub trait VectorIndex:
    Send
    + Sync
    + Debug {
    // Required methods
    fn reader(&self) -> Result<Arc<dyn VectorIndexReader>>;
    fn writer(&self) -> Result<Box<dyn VectorIndexWriter>>;
    fn storage(&self) -> &Arc<dyn Storage>;
    fn close(&self) -> Result<()>;
    fn is_closed(&self) -> bool;
    fn stats(&self) -> Result<VectorIndexStats>;
    fn optimize(&self) -> Result<()>;
    fn searcher(&self) -> Result<Box<dyn VectorIndexSearcher>>;
    fn embedder(&self) -> Arc<dyn Embedder>;

    // Provided methods
    fn refresh(&self) -> Result<()> { ... }
    fn last_wal_seq(&self) -> u64 { ... }
    fn set_last_wal_seq(&self, _seq: u64) -> Result<()> { ... }
}
Expand description

Trait for vector index implementations.

This trait defines the low-level interface for individual vector indexes (Flat, HNSW, IVF, etc.). Each index type implements this trait to provide reader/writer access and basic lifecycle management.

This is analogous to crate::lexical::index::LexicalIndex in the lexical module. For high-level, document-centric operations, see crate::vector::store::VectorStore which manages multiple vector fields and handles document-level operations.

Required Methods§

Source

fn reader(&self) -> Result<Arc<dyn VectorIndexReader>>

Get a reader for this index.

Returns a reader that can be used to query the index.

Source

fn writer(&self) -> Result<Box<dyn VectorIndexWriter>>

Get a writer for this index.

Returns a writer that can be used to add or update vectors.

Source

fn storage(&self) -> &Arc<dyn Storage>

Get the storage backend for this index.

Returns a reference to the underlying storage.

Source

fn close(&self) -> Result<()>

Close the index and release resources.

This should flush any pending writes and release all resources. Uses interior mutability for thread-safe access.

Source

fn is_closed(&self) -> bool

Check if the index is closed.

Returns true if the index has been closed.

Source

fn stats(&self) -> Result<VectorIndexStats>

Get index statistics.

Returns statistics about the index such as vector count, dimension, etc.

Source

fn optimize(&self) -> Result<()>

Optimize the index.

Performs index optimization to improve query performance. Uses interior mutability for thread-safe access.

Source

fn searcher(&self) -> Result<Box<dyn VectorIndexSearcher>>

Create a searcher tailored for this index implementation.

Returns a boxed VectorIndexSearcher capable of executing search/count operations.

Source

fn embedder(&self) -> Arc<dyn Embedder>

Get the embedder associated with this index.

Returns the embedder used to convert documents to vectors.

Provided Methods§

Source

fn refresh(&self) -> Result<()>

Refresh the index metadata from storage.

Should be called after external writes (e.g., by a Writer) to ensure the index state is up-to-date.

Source

fn last_wal_seq(&self) -> u64

Get the last processed WAL sequence number.

Source

fn set_last_wal_seq(&self, _seq: u64) -> Result<()>

Set the last processed WAL sequence number.

Implementors§