anda_db
anda_db is the core crate of Anda DB: an embedded Rust database for AI agents that stores documents, builds multiple index types, and runs structured queries and hybrid retrieval.
It is designed to be linked into your application (not a hosted database service) and persists data via the object_store ecosystem.
Highlights
- Embedded & async: Integrate as a Rust library; built around
tokio. - Object-store persistence: Use local filesystem, S3-compatible storage, in-memory, etc.
- Document schema: Define typed documents via
AndaDBSchemaderive. - Indexes:
- B-Tree for exact match and range filters (powered by
anda_db_btree). - BM25 for full-text retrieval (powered by
anda_db_tfs, requires featurefull). - HNSW for ANN vector search (powered by
anda_db_hnsw).
- B-Tree for exact match and range filters (powered by
- Hybrid search: Combine BM25 + vector search with RRF.
- Encryption (optional): Wrap storage with
anda_object_storefor metadata + AES-256-GCM at rest.
Installation
Add dependencies (pick the object_store backend you need):
[]
= "0.7"
= { = "1", = ["full"] }
= { = "1", = ["derive"] }
# Required to provide an ObjectStore implementation:
= { = "0.13", = ["fs"] }
# Optional (recommended for local filesystem): adds metadata + conditional put support
= "0.3"
Feature flags
default: no extra featuresfull: enables full-text search dependencies (BM25 via Tantivy + jieba integration)
If you want BM25 / hybrid search, enable:
= { = "0.7", = ["full"] }
Quickstart (minimal, in-memory)
This example creates a collection with an HNSW vector index and performs a vector search.
use ;
use InMemory;
use ;
use Arc;
async
Full demo (persistent, BM25 + HNSW + hybrid)
The repo includes a complete runnable example:
- Source: examples/db_demo.rs
- Run:
cargo run -p anda_db --example db_demo --features full
Notes:
- BM25 / hybrid search requires feature
full. - For better tokenization (especially CJK), set a tokenizer (the demo uses
anda_db_tfs::jieba_tokenizer).
Storage backends
AndaDB::connect accepts any Arc<dyn object_store::ObjectStore>.
Local filesystem (recommended)
For local filesystem, wrapping with anda_object_store::MetaStoreBuilder improves correctness/performance by providing metadata and conditional put support:
use MetaStoreBuilder;
use LocalFileSystem;
let store = new.build;
Encryption at rest (optional)
See the EncryptedStoreBuilder examples in ../anda_object_store/README.md.
License
Copyright © 2026 LDC Labs.
ldclabs/anda-db is licensed under the MIT License. See LICENSE for details.