Vector search with Basis
Store and query vectors, then connect your chosen embedding model.
Prerequisites
Use an authorized local Weave source checkout. Add weave-sdk as a path dependency to libs/weave-sdk; its manifest version is 1.1.0. This avoids assuming a public registry artifact. The snippets use the current SDK methods in libs/weave-sdk/src/node.rs.
[dependencies]
weave-sdk = { path = "../weave/libs/weave-sdk" }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }Adjust the path from your application's Cargo.toml. Use an application-owned local data directory. The sample opens local stores and does not start networking.
Add uuid = { version = "1", features = ["v4"] } to dependencies.
Verify vector mechanics
The fixed vectors below are numeric fixtures. They demonstrate nearest-neighbor storage, not semantic quality. Production ingestion and query vectors must use the same model, dimensionality and normalization.
use weave_sdk::prelude::*;
#[tokio::main]
async fn main() -> WeaveResult<()> {
let node = WeaveNode::builder()
.namespace("docs-example")
.identifier("vectors")
.storage_dir("./data/vectors")
.build()
.await?;
node.open_basis("documents").await?;
let document_id = uuid::Uuid::new_v4();
let embedding = vec![1.0_f32, 0.0, 0.0];
node.basis_add("documents", document_id, &embedding).await?;
let hits = node.basis_search("documents", &embedding, 1).await?;
for (id, distance) in hits {
println!("{id}: {distance}");
}
Ok(())
}Connect documents to embeddings
Store source text in Strand or Locus and retain its stable ID alongside each vector. Replace the fixture with a configured embedding provider and record model/version/dimensions with the collection. Resolve returned UUIDs through your application index. Rebuild vectors after incompatible model changes; do not silently mix embeddings.
Basis reference covers exact source declarations; Gnosis can hold related graph metadata. Neither component supplies the embedding model.