Index Overview
| Index | Engine | Purpose | Best For |
|---|---|---|---|
| Lexical | BM25 | Full-text keyword search | Exact terms, error codes, names |
| Vector | Vector search | Semantic similarity search | Natural language, concepts |
| Time | Sorted tuples | Chronological ordering | Timeline queries, auditing |
.mv2 file. No external dependencies or sidecar files.
Lexical Index
The lexical index powers fast, precise keyword search using BM25, a proven ranking algorithm for full-text search.How It Works
- BM25 ranking: Scores documents by term frequency and inverse document frequency
- Tokenization: Breaks text into searchable terms
- Memory-mapped: Uses mmap for efficient disk access
- Embedded: Stored as a snapshot inside the
.mv2file
When to Use
Lexical search excels at finding exact matches:Building the Index
The lexical index is built automatically when you add documents. You can also rebuild it:Disabling Lexical Index
For vector-only workloads, you can disable lexical indexing:Vector Index
The vector index enables semantic search, finding documents by meaning rather than exact keywords.How It Works
- Embeddings: Documents are converted to dense vectors (default: BGE-small, 384 dimensions)
- External providers: Support for OpenAI, Cohere, Voyage, and HuggingFace models
- Vector graph: Fast approximate nearest neighbor search for semantic similarity
- Product Quantization (PQ): Optional 16x compression for large collections
- Embedded: Stored as segments inside the
.mv2file
Embedding Model Options
| Model | Dimensions | Description |
|---|---|---|
| BGE-small (default) | 384 | Built-in, offline, no API key |
| OpenAI text-embedding-3-small | 1536 | High quality, general purpose |
| OpenAI text-embedding-3-large | 3072 | Highest quality |
| Cohere embed-english-v3.0 | 1024 | English documents |
| Voyage voyage-3 | 1024 | Code and technical docs |
When to Use
Vector search excels at understanding intent:Building the Index
Enable embeddings when adding documents:Rebuilding the Index
If vector search isn’t working correctly:Direct Vector Search
For custom embeddings from your own model:Time Index
The time index enables chronological queries and time-travel features.How It Works
- Sorted tuples: Stores
(timestamp, frame_id)pairs in sorted order - MVTI magic: Identified by
MVTIheader bytes - O(log n) lookups: Binary search for efficient time range queries
- Checksummed: Protected by integrity verification
When to Use
Time-based access patterns:Time-Travel Queries
View your memory as it existed at a point in time:Rebuilding the Time Index
If timeline queries return incorrect results:Hybrid Search
Hybrid search (modeauto) combines lexical and semantic results for the best of both worlds.
How It Works
- Parallel query: Both lexical and vector indices are queried
- Result fusion: Scores are combined using reciprocal rank fusion
- Reranking: Top results are reranked for relevance
- Deduplication: Duplicate frames are merged
When to Use
Hybrid search is recommended for most use cases:Performance Comparison
| Mode | Speed | Recall | Best For |
|---|---|---|---|
lex | Fastest | Exact matches | Technical terms, IDs |
sem | Moderate | Semantic similarity | Natural language |
auto | Balanced | Comprehensive | General queries |
Tracks
Tracks are logical groupings for organizing content within a memory.What Tracks Are
- Namespace: Group related documents together
- Filterable: Search within specific tracks
- Metadata: Organizational label stored with each frame
Using Tracks
Common Track Patterns
| Track | Use Case |
|---|---|
documentation | Technical docs and guides |
code | Source code and snippets |
meetings | Meeting notes and transcripts |
research | Papers and references |
archived | Old or deprecated content |
Index Statistics
Check the status of all indices:Best Practices
Index Selection
| Scenario | Recommended Indices |
|---|---|
| Full-featured search | All three (default) |
| Keyword-only search | Lexical only |
| Semantic similarity | Vector only |
| Large collections | All with vector compression |
| Audit/compliance | Time index required |
Performance Tips
- Use
put_many()for batch ingestion: 100-200x faster than individualput()calls - Enable vector compression for large collections to reduce storage
- Rebuild indices if search quality degrades after crashes
- Use hybrid mode for best recall on general queries