Skip to main content

VectorIndex

Trait VectorIndex 

Source
pub trait VectorIndex: Send + Sync {
    // Required methods
    fn model(&self) -> &str;
    fn dim(&self) -> u32;
    fn search(&self, query: &[f32], k: usize) -> Result<Vec<VectorHit>, Error>;
    fn len(&self) -> usize;

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

Read-only approximate-nearest-neighbours surface for node embeddings.

Implementations bind to a single (model, dim) at build time. search returns up to k hits in descending score order, with ties broken by NodeId ASC for byte-stable replay.

Required Methods§

Source

fn model(&self) -> &str

Embedding model this index was built for.

Source

fn dim(&self) -> u32

Vector dimension the index accepts on queries.

Source

fn search(&self, query: &[f32], k: usize) -> Result<Vec<VectorHit>, Error>

Nearest-neighbour lookup. Returns up to k hits.

§Errors

Returns RepoError::VectorDimMismatch if query.len() != self.dim().

Source

fn len(&self) -> usize

Number of indexed vectors.

Provided Methods§

Source

fn is_empty(&self) -> bool

true iff no vectors were indexed.

Implementors§