quickstart (dynvec)
dynvec
HTTP server, populate it with a few vectors, and run a similarity search.
Source:
crates/dynomite-vec/examples/quickstart.rs --
run with
cargo run -p dynvec --example quickstart --features http
What it demonstrates
dynvec, the vector engine that backs Dynomite’s VECTOR search fields,
used directly and standalone. It creates an in-memory store with one
table, seeds a handful of labeled vectors, and serves an HTTP API you can
query.
#![allow(unused)]
fn main() {
use dynvec::api::serve;
use dynvec::distance::Distance;
use dynvec::encoding::Codec;
use dynvec::index::HnswParams;
use dynvec::storage::{IndexAlgorithm, TableSchema, VectorStore};
let store = Arc::new(VectorStore::in_memory());
store.create_table(TableSchema {
name: "demo".to_string(),
dim: 3,
codec: Codec::Int8Quantized,
distance: Distance::Cosine,
hnsw: HnswParams::default(),
algorithm: IndexAlgorithm::Hnsw,
})?;
}
It listens on 127.0.0.1:21900 by default (override with
DYNVEC_LISTEN).
Design decisions and trade-offs
- In-memory store
VectorStore::in_memory()keeps the example dependency-free. The same API backs a persistent store when you want durability.- Int8 quantized codec
- The table uses
Codec::Int8Quantized, which shrinks each vector roughly four-fold versus rawf32at a small recall cost. Choosing the codec at table-creation time is a deliberate space/accuracy trade-off exposed to the caller. - Cosine distance + HNSW
- Cosine similarity over an HNSW index -- the standard combination for
semantic-similarity search. The
DistanceandIndexAlgorithmare per-table so different tables can make different choices. - HTTP surface
- The
httpfeature exposes a REST API, which is why the run command passes--features http. Without it, the store is a library only.
Note
Road not taken: one global vector configuration
Distance metric, codec, and index algorithm are chosen per table rather than globally. A store commonly holds vectors with different dimensionalities and accuracy needs; forcing one setting on all of them would push the trade-off onto the wrong layer. The cost is a slightly larger table schema; the benefit is that each table is tuned to its data.
When to use this pattern
When you want the vector engine without the rest of Dynomite – to
prototype an embedding search, to benchmark a codec/distance combination,
or to understand what the VECTOR fields in
demo_vector_text sit on top of.
Where to go next
demo_vector_textshows the same vector engine reached through theFT.*search surface.- Full-Text, Vector, and Regex Search is the reference for search across Dynomite.