ngt-rs
Rust wrappers for NGT, which provides high-speed approximate nearest neighbor searches against a large volume of data.
Note that NGT's shared memory and large dataset features are available through
cargo features shared_mem
and large_data
respectively.
Usage
Defining the properties of a new index:
use ;
// Defaut properties with vectors of dimension 3
let prop = new?;
// Or customize values (here are the defaults)
let prop = new?
.creation_edge_size?
.search_edge_size?
.object_type?
.distance_type?;
Creating/Opening an index and using it:
use ;
// Create a new index
let prop = new?;
let index = create?;
// Open an existing index
let mut index = open?;
// Insert two vectors and get their id
let vec1 = vec!;
let vec2 = vec!;
let id1 = index.insert?;
let id2 = index.insert?;
// Actually build the index (not yet persisted on disk)
// This is required in order to be able to search vectors
index.build?;
// Perform a vector search (with 1 result)
let res = index.search?;
assert_eq!;
assert_eq!;
// Remove a vector and check that it is not present anymore
index.remove?;
let res = index.get_vec;
assert!;
// Verify that now our search result is different
let res = index.search?;
assert_eq!;
assert_eq!;
// Persist index on disk
index.persist?;