Trait IndexBackend

Source
pub trait IndexBackend: Send + Sync {
    // Required methods
    fn insert(
        &self,
        entity_id: u64,
        vector: &[f32],
        timestamp: i64,
    ) -> Result<u32, IndexError>;
    fn search(
        &self,
        query: &[f32],
        k: usize,
        filter: TemporalFilter,
        alpha: f32,
        query_timestamp: i64,
    ) -> Result<Vec<ScoredResult>, QueryError>;
    fn remove(&self, point_id: u64) -> Result<(), IndexError>;
    fn len(&self) -> usize;

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

Index backend for approximate nearest neighbor search.

Abstracts over the indexing structure (HNSW, brute-force, etc.).

Required Methods§

Source

fn insert( &self, entity_id: u64, vector: &[f32], timestamp: i64, ) -> Result<u32, IndexError>

Insert a point into the index.

Source

fn search( &self, query: &[f32], k: usize, filter: TemporalFilter, alpha: f32, query_timestamp: i64, ) -> Result<Vec<ScoredResult>, QueryError>

Search for the k nearest neighbors with temporal filtering.

alpha controls the semantic vs temporal weight:

  • alpha = 1.0: pure semantic distance
  • alpha = 0.0: pure temporal distance

query_timestamp is the reference time for temporal distance computation.

Source

fn remove(&self, point_id: u64) -> Result<(), IndexError>

Remove a point from the index.

Source

fn len(&self) -> usize

Number of points in the index.

Provided Methods§

Source

fn is_empty(&self) -> bool

Whether the index is empty.

Implementors§