Expand description
Vector database allowing for efficient search of nearest neighbors.
The approach is described in “FANN: Vector Search in 200 Lines of Rust” by Nikhil Garg and Navya Mehta.
§Example
use vector::Index;
let vectors = vec![
[4.0, 2.0],
[5.0, 7.0],
[2.0, 9.0],
[7.0, 8.0],
];
let index = Index::build(&vectors, 1, 1, 42);
let query = [5.0, 5.0];
let (indices, distances): (Vec<_>, Vec<_>) = index
.search(&vectors, &query, 2)
.into_iter()
.unzip();
assert_eq!(indices, &[1, 0]);
Structs§
- Index
- An index.
Type Aliases§
- Vector
- A vector.