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.
Sourcepub fn load(dir: &Path) -> MenteResult<Self>
pub fn load(dir: &Path) -> MenteResult<Self>
Load all indexes from the given directory.
Sourcepub fn index_memory(&self, node: &MemoryNode)
pub fn index_memory(&self, node: &MemoryNode)
Index a memory node across all indexes.
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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for IndexManager
impl !RefUnwindSafe for IndexManager
impl Send for IndexManager
impl Sync for IndexManager
impl Unpin for IndexManager
impl UnsafeUnpin for IndexManager
impl UnwindSafe for IndexManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more