OriginChainDB
Vector

Vector examples

← All examples

Start by writing an embedding, then choose the distance metric recommended by the model that produced it. The maintenance recipes cover index coverage, repair and compression.

Check the vector write-and-search loopThe three-number sample tests the API; it is not an example of text meaning.
  1. Store sample-1Write the complete three-value vector into learning.sample.
  2. Search with the same valuesKeep dimension and metric identical to the write.
  3. Check the returned IDLook for sample-1 before moving to model-generated embeddings.

Try a complete small example

This uses three made-up numbers to check the write-and-search flow. It does not demonstrate the meaning of text. Use the tenant-scoped connection from the connection notes, and keep learning.sample separate from collections using a different dimension or metric.

First save one vector:

curl --fail-with-body -X POST "https://$OC_HOST/v1/tenants/$OC_TENANT/vector/learning.sample/put" \
  -H "Authorization: Bearer $OC_TOKEN" -H "Content-Type: application/json" \
  -d '{"id":"sample-1","embedding":[1.0,0.0,0.0],"dim":3,"metric":"cosine"}'

Then search with the same three values:

curl --fail-with-body -X POST "https://$OC_HOST/v1/tenants/$OC_TENANT/vector/learning.sample/topk" \
  -H "Authorization: Bearer $OC_TOKEN" -H "Content-Type: application/json" \
  -d '{"query":[1.0,0.0,0.0],"k":1,"dim":3,"metric":"cosine"}'

Look for sample-1 in the result. k: 1 asks for at most one match. The dimension and metric agree in both requests. Next, use a real embedding from your chosen model; the model supplies the numbers, while the database stores and compares them.

Search by similarity

Before adapting a recipe

Use a test database, load the named sample data, and check the expected result. Read each page’s limits before changing the query. See connection and SDK notes.

© 2026 Silicoyn Technologies Pvt Ltd

On this page