ANNex
ANNex — ANN + index — is an in-memory vector search engine in Rust. It implements HNSW-based approximate nearest-neighbor search, in-place payload filtering, snapshot persistence, and WAL-backed recovery.
- MSRV: Rust 1.85 (2024 edition).
- Scope: Rust library. There is no HTTP/gRPC server or client SDK — callers
embed
Segmentinside their own service.
Features
- HNSW indexing for approximate nearest-neighbor search
- Distance metrics: cosine, euclidean, dot
- Schema-agnostic per-point payloads (ints, floats, strings, bools, homogeneous lists)
- Equality and comparison filters with boolean composition (
And/Or/Not) - Inverted index acceleration on scalar payload fields
- Tombstone deletion with automatic purge/rebuild past a configurable threshold
- Snapshot persistence, background snapshotting, and WAL replay on load
Install
[]
= "0.1"
Quickstart
use HashMap;
use ;
Thread safety
A single Segment is not internally synchronised for writes. For
multi-threaded workloads, wrap it in Arc<RwLock<Segment>> (aliased as
SharedSegment) and coordinate access through the lock:
- take a read guard for
search*calls, - take a write guard for
insert*,delete,update_payload, andpurge.
Background snapshotting (see start_background_snapshots) takes only read
locks and is safe to run alongside concurrent readers.
Filtering model
- Payloads are per-point key/value maps (
Payload). - Missing fields evaluate to false for match/compare checks.
- Supported scalar types:
Int,Float,Str,Bool, plus homogeneous lists. - Filters compose via
Filter::Match,Filter::Compare,Filter::And,Filter::Or, andFilter::Not. - Scalar payload fields can be routed through the inverted index for fast exact-match filtering.
Configuration
Runtime tuning is driven by VECTORDB_* environment variables read once at
startup (search budgets, purge thresholds, telemetry paths, dataset paths for
the benchmark harnesses). The prefix predates the ANNex rename and is
retained for compatibility. See .env.example for the full
list and docs/test-config.md for a per-test matrix.
Project layout
src/segment/—Segmentlifecycle, persistence, WAL, background snapshottingsrc/vector/hnsw/— HNSW index internalssrc/payload_storage/— payload evaluation and inverted indexsrc/bin/— snapshot inspection and analysis utilitiestests/— correctness, persistence, recall, and dataset-driven harnessesscripts/— experiment pipelinedocs/— operational notes, benchmark workflows, dataset setup
Docs
- Dataset setup: docs/data-download.md
- Test and env-var matrix: docs/test-config.md
- Snapshot naming and build manifests: docs/index-construction.md
- Runtime persistence and operations: docs/operations.md
- Benchmark commands and recorded results: docs/benchmarks.md
- Recall frontier pipeline: docs/recall_frontier_pipeline.md
Utilities
Logging
Logging uses the log crate with targets such as vector::hnsw, segment,
payload, and filter. Wire up any log backend (e.g. env_logger,
tracing-log) and control verbosity through RUST_LOG.
Roadmap
ANNEX_*env-var prefix alongsideVECTORDB_*- Optional Python bindings
- Additional distance metrics
- Multi-segment collection layer
Contributing
Contributions welcome — see CONTRIBUTING.md. By participating you agree to abide by the Code of Conduct. To report a vulnerability privately, see SECURITY.md.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.