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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! # Nitrite Vector — HNSW ANN index & RAG store for Nitrite
//!
//! This crate adds an approximate-nearest-neighbour (ANN) vector index to the
//! Nitrite embedded database, backed by a hand-rolled, persistent
//! **HNSW** (Hierarchical Navigable Small World) graph, plus a thin
//! [`RagStore`] convenience layer for retrieval-augmented-generation workloads.
//!
//! Embeddings are **provided by the caller** (bring-your-own vectors); this
//! crate does not generate embeddings.
//!
//! ## Quick start (raw collection API)
//!
//! ```rust,ignore
//! use nitrite::nitrite::Nitrite;
//! use nitrite::common::PersistentCollection;
//! use nitrite_vector::{VectorModule, VectorIndexConfig, vector_index_options, vector_field};
//! use nitrite_vector::distance::Metric;
//!
//! let db = Nitrite::builder()
//! .load_module(VectorModule::new(VectorIndexConfig::new(3, Metric::Cosine)))
//! .open_or_create(None, None)?;
//!
//! let collection = db.collection("docs")?;
//! collection.create_index(vec!["embedding"], &vector_index_options())?;
//!
//! // ... insert documents whose `embedding` field is a numeric array ...
//!
//! let filter = vector_field("embedding").nearest(vec![0.1, 0.2, 0.3], 5).build();
//! let results = collection.find(filter)?;
//! ```
//!
//! ## RAG store
//!
//! ```rust,ignore
//! use nitrite_vector::RagStore;
//! use nitrite_vector::distance::Metric;
//!
//! // `Metric::Cosine` must match the metric configured on the VectorModule.
//! let store = RagStore::create(&db, "kb", Metric::Cosine)?;
//! store.add("hello world", embedding, doc!{ "source": "wiki" })?;
//! let hits = store.search(query_vector, 5).run()?;
//! ```
//!
//! ## Security note
//!
//! Vectors are stored **in plaintext** by both backends (embeddings are
//! generally invertible back to content — treat them as the data itself). The
//! DiskANN backend writes its files next to the database, outside whatever the
//! storage adapter provides, and therefore requires a persistent `db_path`.
pub use ;
pub use Metric;
pub use ;
pub use ;
pub use VectorIndexer;
pub use ;
pub use Precision;
pub use ;
pub use ;
/// Creates [`IndexOptions`](nitrite::index::IndexOptions) for a vector index.
///
/// Use with `collection.create_index(vec!["embedding"], &vector_index_options())`.