A zero-dependency vector and hybrid search engine in pure Rust.
Version 0.2.0 · nowii-core · HNSW + BM25 + RRF · WAL + Snapshot
Overview | Preview | Benchmarks | Features | Quick Start | HTTP API | Storage | Development | Contact
Most vector and search engines pull in heavy external crates, complex runtimes, or bloated abstractions before you can even test a query. VectorCore takes a zero-dependency, systems-first approach: it implements dense vector indexing, sparse lexical ranking, hybrid fusion, crash-safe logging, binary snapshots, and an HTTP/1.1 JSON server from scratch using only the Rust standard library.
VectorCore combines an HNSW approximate nearest neighbor graph with an Okapi BM25 inverted index and merges rankings via Reciprocal Rank Fusion (RRF). Every write can be durably appended to a CRC32-verified Write-Ahead Log (VCW1) and persisted as a full binary snapshot (VCS1).
VectorCore
├── HNSW Graph Index (Cosine, Euclidean, Dot Product)
├── BM25 Inverted Index & Tokenizer
├── Reciprocal Rank Fusion (RRF) Hybrid Query Engine
├── Crash-Safe WAL (VCW1 + CRC32 IEEE + fsync)
├── Binary Snapshots (VCS1 + CRC32 IEEE)
└── Zero-Dependency HTTP/1.1 Server & CLI Benchmark
VectorCore is written in pure Rust (edition = "2021") with no runtime dependencies in Cargo.toml.
Sub-millisecond Vector Search: 5,000 vectors indexed with
p50: 174.9 usmedian query latency and94.80%recall on Apple Silicon.
Measured on Apple Silicon (release / bench profile, 5,000 vectors, dim=64, top_k=10, ef_search=64):
| Metric | Result | Notes |
|---|---|---|
| Ingestion (5,000 vectors, dim=64) | 1557.59 ms |
Full HNSW graph construction |
| Latency p50 | 174.9 us (0.17 ms) |
Sub-millisecond median query latency |
| Latency p95 | 196.0 us (0.19 ms) |
95th percentile search latency |
| Latency p99 | 213.0 us (0.21 ms) |
Tail latency under 0.25 ms |
| Mean Recall@10 | 94.80% |
Measured against exact brute-force search |
Run it yourself:
cargo bench --bench search_bench
- Zero External Dependencies: Built purely on Rust's standard library (
std) with no third-party crates required for core indexing, storage, JSON parsing, or HTTP serving. - HNSW Graph (
src/index/hnsw.rs): Multi-layer Hierarchical Navigable Small World index with configurablem,ef_construction, andef_search, supportingCosine,Euclidean, andDotProductmetrics plus exact brute-force search for recall verification. - BM25 Inverted Index (
src/index/inverted.rs): Case-insensitive alphanumeric tokenization, term frequency tracking, document length normalization, and Okapi BM25 ranking (k1,b). - Hybrid RRF Search (
src/query/hybrid.rs): Combines dense vector candidates and sparse BM25 lexical matches using Reciprocal Rank Fusion (rrf_k, configurable vector and BM25 weights). - Write-Ahead Log (
src/storage/wal.rs): Append-only binary log (VCW1) with payload length, CRC32 IEEE checksum,sync_data(fsync), and safe replay that stops cleanly at corrupt or truncated tail records. - Binary Snapshots (
src/storage/snapshot.rs): Full state serialization (VCS1) with CRC32 IEEE integrity verification covering documents, HNSW nodes/neighbors/entry-point/max-level/RNG state, and BM25 structures. - HTTP/1.1 JSON Server (
src/server/http.rs): LightweightTcpListenerserver supporting document ingestion, hybrid search, health checks, and snapshot save/load endpoints.
- Compiler: Rust toolchain (
cargoandrustc, Rust 2021 edition). - OS: macOS, Linux, or Windows.
git clone https://github.com/nowii-core/vectorcore.git
cd vectorcorecargo test
cargo run --release --example semantic_search
cargo bench --bench search_benchcargo run --release --bin vectorcore_serverBy default, the server listens on:
http://127.0.0.1:8080
Once vectorcore_server is running on 127.0.0.1:8080, you can interact with it using curl:
curl -s http://127.0.0.1:8080/healthcurl -s -X POST http://127.0.0.1:8080/ingest \
-H "Content-Type: application/json" \
-d '{"id":1,"text":"Rust HNSW hybrid search engine","vector":[0.9,0.1,0.0]}'curl -s -X POST http://127.0.0.1:8080/search \
-H "Content-Type: application/json" \
-d '{"query":"Rust HNSW","vector":[0.9,0.1,0.0],"top_k":3}'curl -s -X POST http://127.0.0.1:8080/snapshot/save
curl -s -X POST http://127.0.0.1:8080/snapshot/loadVectorCore separates append-only durability from full index snapshots:
- WAL (
vectorcore.wal, magicVCW1): Appends each ingested document with a CRC32 IEEE checksum and flushes withsync_data(). On startup,vectorcore_serverreplays entries not yet present in the loaded snapshot. - Snapshot (
vectorcore.vcsnap, magicVCS1): Writes a single CRC32-protected binary image of the entireHybridSearchEnginestate for fast reloads without replaying or rebuilding from scratch.
cargo testCargo.toml Package manifest (zero external dependencies)
benches/
search_bench.rs Latency (p50/p95/p99) and Recall@10 benchmark
examples/
semantic_search.rs End-to-end WAL, snapshot, and hybrid search demo
src/
lib.rs Core types (Document, SearchHit) and JSON helpers
index/
distance.rs Cosine, L2, dot product, and vector normalization
hnsw.rs Multi-layer HNSW graph and brute-force baseline
inverted.rs Tokenizer and Okapi BM25 inverted index
query/
hybrid.rs Reciprocal Rank Fusion (RRF) search engine
storage/
wal.rs CRC32 write-ahead log and crash recovery
snapshot.rs CRC32 binary snapshot save/load
server/
http.rs HTTP/1.1 server and JSON endpoint handlers
bin/
vectorcore_server.rs Server binary with snapshot + WAL recovery
vectorcore_bench.rs Benchmark helper binary
- Maintainer: @nowii-core
- Repository: github.com/nowii-core/vectorcore
- Issues & PRs: Open an issue or pull request directly in the repository.
