recern_vector/lib.rs
1//! Recern Vector — a single-file, embedded, inspectable vector database.
2//!
3//! A database is one file holding any number of collections. Each collection
4//! stores vectors of a fixed dimension, optional JSON metadata, and an HNSW
5//! index whose internals can be inspected through [`Collection::stats`],
6//! [`Collection::explain`] and [`Collection::estimate_recall`].
7//!
8//! ```no_run
9//! use recern_vector::{CollectionConfig, Database, Metric, SearchOptions};
10//!
11//! let mut db = Database::open_or_create("docs.rvec")?;
12//! let docs = db.create_collection("docs", CollectionConfig::new(3, Metric::Cosine))?;
13//! docs.upsert("a", &[0.1, 0.9, 0.0], None)?;
14//! docs.upsert("b", &[0.8, 0.1, 0.1], None)?;
15//! let hits = docs.search(&[0.2, 0.8, 0.0], 1, &SearchOptions::default())?;
16//! assert_eq!(hits[0].id, "a");
17//! db.save()?;
18//! # Ok::<(), recern_vector::Error>(())
19//! ```
20
21mod collection;
22mod database;
23mod error;
24mod filter;
25mod hnsw;
26mod metric;
27mod rng;
28mod storage;
29
30pub use collection::{
31 Collection, CollectionConfig, CollectionStats, RecallOptions, RecallPoint, RecallReport,
32 Record, SearchHit, SearchOptions, SearchReport, Strategy,
33};
34pub use database::Database;
35pub use error::{Error, Result};
36pub use filter::Filter;
37pub use hnsw::HnswParams;
38pub use metric::Metric;
39pub use storage::FORMAT_VERSION;