Vector examples
← All examples
Vectors on OriginChainDB live on the runtime endpoint POST /v1/tenants/:t/vector/:table/put - they are not declared on the row schema. The id field is what links a vector back to a row, so use the row's primary key.
13 examples, each on its own page. The first seven cover the write and the query: insert embeddings, search by cosine, L2 or dot product, switch between fast and high-recall mode, and restrict a search with a metadata filter. The rest cover the parts you cannot guess - deleting vectors, installing and retraining an IVF index, checking what the index actually covers, diagnosing and rebuilding an HNSW graph, building a compressed index, and fusing a sparse and a dense search into one call. Every page carries the request in cURL + Python + TypeScript + Go, the response shape, how it works, and common mistakes.
Save one vector under an ID. The simplest write.
Attach arbitrary tags to each vector so you can later filter searches on them.
The default metric for text embeddings (OpenAI, Cohere, BGE, E5).
Euclidean distance. Use when the absolute magnitude of vectors carries signal.
Inner product. Use when your embeddings are already unit-normalised.
Trade some recall for ~3x faster results. Useful when latency matters more than perfect ranking.
Restrict the search to vectors whose metadata matches a filter. Applied during search, not after.
Remove one embedding by id, or up to 10,000 in one bulk call. Both are idempotent.
Bootstrap an IVF index: train k-means over the stored corpus, install it, and read back what is installed.
How much of the table the index actually covers, how lopsided the cells are, and whether to retrain.
Find out whether the graph can still be walked, prove which metric it was built for, then rebuild it in place.
A product-quantized IVF index from a named preset - what it resolves to, and what it keeps on disk.
One call that runs both searches and fuses the two rankings server-side.