pub struct IndexManager {
pub hnsw: HnswIndex,
pub bm25: Bm25Index,
pub bitmap: BitmapIndex,
pub temporal: TemporalIndex,
pub salience: SalienceIndex,
}Expand description
Owns all index types and provides unified indexing and hybrid search.
Fields§
§hnsw: HnswIndexVector similarity index.
bm25: Bm25IndexBM25 full-text index for keyword search.
bitmap: BitmapIndexTag and attribute bitmap index.
temporal: TemporalIndexTimestamp range index.
salience: SalienceIndexImportance score index.
Implementations§
Source§impl IndexManager
impl IndexManager
Sourcepub fn new(config: IndexManagerConfig) -> Self
pub fn new(config: IndexManagerConfig) -> Self
Create a new index manager with the given configuration.
Sourcepub fn save(&self, dir: &Path) -> MenteResult<()>
pub fn save(&self, dir: &Path) -> MenteResult<()>
Save all indexes to the given directory (bincode format).
Sourcepub fn load(dir: &Path) -> MenteResult<Self>
pub fn load(dir: &Path) -> MenteResult<Self>
Load all indexes from the given directory. Tries .bin first, falls back to .json.
Sourcepub fn index_memory(&self, node: &MemoryNode)
pub fn index_memory(&self, node: &MemoryNode)
Index a memory node across all indexes.
Sourcepub fn contains_vector(&self, id: MemoryId) -> bool
pub fn contains_vector(&self, id: MemoryId) -> bool
True when the memory’s vector is indexed and live.
Sourcepub fn vector_ids(&self) -> Vec<MemoryId>
pub fn vector_ids(&self) -> Vec<MemoryId>
All live vector indexed memory ids.
Sourcepub fn remove_vector_only(&self, id: MemoryId)
pub fn remove_vector_only(&self, id: MemoryId)
Tombstone a vector whose backing page no longer exists; used by open time reconciliation when a snapshot is newer than the last forget.
Sourcepub fn remove_memory(&self, id: MemoryId, node: &MemoryNode)
pub fn remove_memory(&self, id: MemoryId, node: &MemoryNode)
Remove a memory from all indexes.
Sourcepub fn hybrid_search(
&self,
query_embedding: &[f32],
tags: Option<&[&str]>,
time_range: Option<(Timestamp, Timestamp)>,
k: usize,
) -> Vec<(MemoryId, f32)>
pub fn hybrid_search( &self, query_embedding: &[f32], tags: Option<&[&str]>, time_range: Option<(Timestamp, Timestamp)>, k: usize, ) -> Vec<(MemoryId, f32)>
Hybrid search combining vector similarity, BM25 keyword matching, tag filtering, time range, and salience.
Strategy:
- Vector search (HNSW) for top candidates
- BM25 keyword search for top candidates
- Merge via Reciprocal Rank Fusion (RRF)
- Filter by tags and time range
- Boost by salience and recency
- Return top k results
Sourcepub fn hybrid_search_with_query(
&self,
query_embedding: &[f32],
query_text: Option<&str>,
tags: Option<&[&str]>,
time_range: Option<(Timestamp, Timestamp)>,
k: usize,
) -> Vec<(MemoryId, f32)>
pub fn hybrid_search_with_query( &self, query_embedding: &[f32], query_text: Option<&str>, tags: Option<&[&str]>, time_range: Option<(Timestamp, Timestamp)>, k: usize, ) -> Vec<(MemoryId, f32)>
Hybrid search with an optional text query for BM25 matching.
When query_text is provided, BM25 results are merged with vector
results via RRF. When None, behaves like vector-only search.