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
//! Index implementations for EdgeVec.
//!
//! This module provides different indexing strategies for vector search:
//!
//! - [`FlatIndex`]: Brute-force search for small datasets (<10k vectors)
//! with 100% recall guarantee and O(1) insert.
//!
//! # Choosing an Index
//!
//! | Index | Best For | Recall | Insert | Search |
//! |-------|----------|--------|--------|--------|
//! | [`FlatIndex`] | <10k vectors | 100% | O(1) | O(n·d) |
//! | [`HnswIndex`](crate::hnsw::HnswIndex) | >10k vectors | ~95% | O(log n) | O(log n) |
//!
//! # Example
//!
//! ```rust
//! use edgevec::index::{FlatIndex, FlatIndexConfig, DistanceMetric};
//!
//! // Create a flat index for 128-dimensional vectors
//! let config = FlatIndexConfig::new(128)
//! .with_metric(DistanceMetric::Cosine);
//! let mut index = FlatIndex::new(config);
//!
//! // Insert vectors (O(1) operation)
//! let id = index.insert(&[0.1; 128]).unwrap();
//!
//! // Get vector by ID
//! let vector = index.get(id).unwrap();
//! ```
pub use ;