Skip to main content

VectorSearchEngine

Trait VectorSearchEngine 

Source
pub trait VectorSearchEngine: Send + Sync {
    // Required methods
    fn add_vector(
        &mut self,
        memory_id: Uuid,
        galaxy: Galaxy,
        embedding: Vec<f32>,
    );
    fn remove_vector(&mut self, memory_id: Uuid) -> bool;
    fn search_vectors(
        &self,
        query: &[f32],
        limit: usize,
        galaxy_filter: Option<Galaxy>,
    ) -> Vec<VectorSearchResult>;
    fn search_similar_vectors(
        &self,
        memory_id: Uuid,
        limit: usize,
    ) -> Vec<VectorSearchResult>;
    fn vector_count(&self) -> usize;
    fn load_vectors(&mut self, store: &MemoryStore) -> Result<()>;
    fn clear_vectors(&mut self);

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

Trait for pluggable vector search backends.

Implemented by:

  • VectorStore — in-memory brute-force cosine similarity (default)
  • LanceVectorStore — LanceDB-backed ANN search (feature-gated under lancedb)

Required Methods§

Source

fn add_vector(&mut self, memory_id: Uuid, galaxy: Galaxy, embedding: Vec<f32>)

Add a vector to the index.

Source

fn remove_vector(&mut self, memory_id: Uuid) -> bool

Remove a vector from the index.

Source

fn search_vectors( &self, query: &[f32], limit: usize, galaxy_filter: Option<Galaxy>, ) -> Vec<VectorSearchResult>

Search for the most similar vectors to a query embedding.

Returns results sorted by similarity (highest first). Optionally filter by galaxy.

Source

fn search_similar_vectors( &self, memory_id: Uuid, limit: usize, ) -> Vec<VectorSearchResult>

Search for similar vectors to a memory’s own embedding.

Excludes the memory itself from results.

Source

fn vector_count(&self) -> usize

Get the number of indexed vectors.

Source

fn load_vectors(&mut self, store: &MemoryStore) -> Result<()>

Load all embeddings from the LMDB Embeddings galaxy.

Source

fn clear_vectors(&mut self)

Clear the index.

Provided Methods§

Source

fn is_index_empty(&self) -> bool

Whether the index is empty.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§