Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Basic Usage

Workflow Overview

Using Chassis involves three steps:

  1. Open: Initialize the VectorIndex.
  2. Write: Add vectors and flush to disk.
  3. Read: Search for nearest neighbors.

1. Initialization

#![allow(unused)]
fn main() {
use chassis_core::{VectorIndex, IndexOptions};

let options = IndexOptions {
    max_connections: 16,
    ef_construction: 200,
    ef_search: 50,
    ..IndexOptions::default()
};

let mut index = VectorIndex::open("./data.chassis", 1536, options)?;
}

2. Insertion

Chassis assigns a sequential ID (u64) to every vector you add. You should store this ID in your external database (e.g., SQLite/Postgres) to map it back to your application data.

#![allow(unused)]
fn main() {
let embedding = compute_embedding("Example text"); // [f32; 1536]

let id = index.add(&embedding)?;
println!("Stored vector at ID: {}", id);

// Important: Commit to disk!
index.flush()?;
}

Search is thread-safe and can run concurrently with other searches (but not with writes). Other processes can search the same file with IndexReader while this one writes.

#![allow(unused)]
fn main() {
let query = compute_embedding("Search query");
let k = 5;

let results = index.search(&query, k)?;

println!("Found {} matches:", results.len());
for res in results {
    println!("- ID: {}, Score: {}", res.id, res.distance);
}
}