Skip to main content

Module db

Module db 

Source
Expand description

Embedded, no-server API — the primary way to use vecdb.

Open a directory as a Db, create or open a Collection, then insert and query in-process. No network, no daemon, no docker.

use vecdb_core::Db;
use serde_json::json;

let db = Db::open("data.vecdb")?;
let mut docs = db.open_or_create("docs", 4)?;
docs.insert("a", vec![0.1, 0.2, 0.3, 0.4], json!({ "title": "hello" }))?;
let hits = docs.query(&[0.1, 0.2, 0.3, 0.4], 5)?;

Structs§

Collection
A single collection: an owned, in-process handle to one collection’s storage. Insert with &mut, query with &. Data is durable via the WAL on every insert; call Collection::flush (or drop the handle) to also persist the dense/sparse indexes for a fast reopen.
Db
A vecdb database: a handle to a directory that holds one or more collections. Cheap to clone-by-reopen; owns no file handles itself — each Collection it hands out owns its own storage.