git-vdb 0.4.0

An embedded vector database backed by immutable Git trees
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use git_vdb::{open, Condition, Filter, Point, Query};
use serde_json::json;

fn main() -> git_vdb::Result<()> {
    let temporary = tempfile::TempDir::new()?;
    let docs = open(temporary.path().join("vectors.git"))?.collection("docs");
    docs.upsert([
        Point::new("guide", [1.0, 0.0]).with_metadata(json!({"kind": "docs"}))?,
        Point::new("code", [0.9, 0.1]).with_metadata(json!({"kind": "source"}))?,
    ])?;
    let result = docs.advanced()?.query(
        Query::new([1.0, 0.0], 5)
            .with_filter(Filter::must([Condition::matches("kind", "docs")]))
            .with_payload(),
    )?;
    assert_eq!(result.points[0].id.to_string(), "guide");
    Ok(())
}