Getting started
This page takes you from nothing to a first search, in Python or Rust. From C, start with the C API.
Python
pip install chassisdb
from chassisdb import VectorIndex
index = VectorIndex("quickstart.chassis", dimensions=3) # created if it doesn't exist
index.add([1.0, 0.0, 0.0]) # id 0
index.add([0.0, 1.0, 0.0]) # id 1
index.add([0.0, 0.0, 1.0]) # id 2
index.flush() # on disk once this returns
results = index.search([1.0, 0.1, 0.0], k=1)
print("nearest:", results[0].id) # 0
The Python docs go on from here: batches, your own ids, options and every method.
Rust
Add Chassis to your Cargo.toml:
[dependencies]
chassisdb = "0.9"
use chassisdb::{IndexOptions, VectorIndex};
fn main() -> chassisdb::Result<()> {
// Created if it doesn't exist
let mut index = VectorIndex::open("quickstart.chassis", 3, IndexOptions::default())?;
index.add(&[1.0, 0.0, 0.0])?; // id 0
index.add(&[0.0, 1.0, 0.0])?; // id 1
index.add(&[0.0, 0.0, 1.0])?; // id 2
index.flush()?; // on disk once this returns
let results = index.search(&[1.0, 0.1, 0.0], 1)?;
assert_eq!(results[0].id, 0);
println!("nearest: {}", results[0].id);
Ok(())
}
A debug build runs Chassis’s arithmetic many times slower. To build Chassis optimized while your own crate stays in debug:
[profile.dev.package.chassisdb]
opt-level = 3
Basic usage goes on from here, and the Rust API has every method.