Rust API
1.0.0 stabilizes the public API and strengthens input validation and crash recovery. Paged format 3, incremental saves and automatic checkpoints remain available. See policy, statistics, examples and failure behavior.
For the portable API (embedded Recern, Recern HTTP and Qdrant), see portable clients and release packages. The native API remains available. The new persistence policy is described in the persistence guide above.
cargo add recern-vector
The full API reference is on docs.rs/recern-vector. This page is a map of the main types.
| Type | Role |
|---|---|
Database |
A database file. create, open, open_or_create, create_collection, collection, collection_mut, drop_collection, collections, save |
CollectionConfig |
CollectionConfig::new(dim, Metric::Cosine), optionally .with_hnsw(HnswParams { m, ef_construction, ef_search }) |
Collection |
upsert, upsert_many, upsert_many_with_threads, delete, get, search, explain, stats, estimate_recall, compact, len, contains |
SearchOptions |
SearchOptions::default().ef(64).filter(f), or .exact() |
Filter |
Filter::from_json(&value), Filter::eq, Filter::is_in, Filter::between, Filter::And, Filter::Range. See Filters |
SearchHit, SearchReport, Strategy |
Search results and how they were found |
CollectionStats, RecallOptions, RecallReport, RecallPoint |
Introspection, see Inspecting and tuning |
Error, Result |
Every fallible call returns recern_vector::Result<T> |
use recern_vector::{CollectionConfig, Database, Metric, SearchOptions};
let mut db = Database::open_or_create("docs.rvec")?;
let docs = db.create_collection("docs", CollectionConfig::new(3, Metric::Cosine))?;
docs.upsert("a", &[0.1, 0.9, 0.0], None)?;
docs.upsert("b", &[0.8, 0.1, 0.1], None)?;
let hits = docs.search(&[0.2, 0.8, 0.0], 1, &SearchOptions::default())?;
assert_eq!(hits[0].id, "a");
db.save()?;
upsert_many takes any iterator of (id, vector, metadata) where the id is Into<String>, the vector is AsRef<[f32]> and the metadata is Option<serde_json::Value>.
Database and Collection are Send + Sync. Searches take &self and can run from many threads at once; writes take &mut self.
A complete program: quickstart.rs.
Version 0.3.0 adds Database::identity() and Collection::records_page(offset, limit) -> Result<RecordPage>. RecordPage contains bounded records and an optional next_offset; it skips tombstones and replacements. Limits are 1–10,000 and offsets are valid only while the collection is unchanged. Use a read-only snapshot for stable iteration. Portable Python, Rust and Node clients are released in 0.4.0; see portable clients.
Version 0.2.0 adds Database::open_read_only, Database::checkpoint, Database::format_version and CollectionConfig::with_quantization(Quantization::Int8). save() commits to WAL; checkpoint before transporting a standalone file. See file format.