1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Core embedded database primitives for building durable AI memory systems.
//!
//! `anda_db` combines three retrieval modes behind a single collection model:
//!
//! - B-Tree indexes for exact match and range filters
//! - BM25 indexes for full-text retrieval
//! - HNSW indexes for vector similarity search
//!
//! The crate is designed for agent memory workloads where data must be:
//!
//! - schema-validated on write
//! - incrementally searchable through multiple index types
//! - persisted to a generic `object_store` backend
//! - recoverable after partial flushes or process restarts
//!
//! Typical usage:
//!
//! 1. Create or connect to an [`database::AndaDB`]
//! 2. Create or open a [`collection::Collection`]
//! 3. Define a schema via [`schema`] or `AndaDBSchema`
//! 4. Add B-Tree, BM25, and/or HNSW indexes
//! 5. Insert documents and query them through [`query`]
//!
//! Feature flags:
//!
//! - `full`: enables full-text search integrations exposed by the workspace setup
//! - `tantivy`: enables the Tantivy-backed text search dependency
//! - `tantivy-jieba`: enables Tantivy plus Jieba tokenization support
//!
//! See also the technical guide in `docs/anda_db.md` for architecture,
//! lifecycle, indexing, and operational guidance.
/// Collection-level document storage, indexing, and query execution.
/// Database-level lifecycle and collection management.
/// Error types returned by the core library.
/// Index abstractions and concrete B-Tree, BM25, and HNSW integrations.
/// Query structures for hybrid search, filters, and reranking.
/// Schema types re-exported from `anda_db_schema`.
/// Object-store-backed persistence, compression, and cached I/O.
/// Returns the current Unix timestamp in milliseconds.
///
/// The crate uses millisecond timestamps for metadata bookkeeping,
/// collection statistics, and periodic flush coordination.