OriginChainDB
Database endpoints

Find nearest vectors

Returns the k stored vectors nearest to a query vector, optionally filtered by metadata.

POST /v1/tenants/{tenant}/vector/{table}/topk

Find embeddings nearest to a queryScores depend on the distance metric; k is a result limit.
  1. Prepare a compatible query vectorMatch the stored embeddings' dimension and metric.
  2. Search with optional filtersLimit candidates to the metadata you need.
  3. Read IDs and scoresUse each ID to retrieve the source data.

Before you start

Use your database bearer token.

Connection setup

Store dense vectors in the collection before searching it. The example uses demo_vectors; scores depend on your data and distance metric.

Path parameters

FieldTypeRequired
tenantstringRequired
tablestringRequired

Headers

FieldTypeRequiredDescription
x-oc-db-userstringOptionalActing database user (role, grant and row-policy checks). Send with x-oc-db-key.
x-oc-db-keystringOptionalAPI key of the x-oc-db-user user.

Request body

application/json

Limits and accepted values
  • The query vector field is `query` (not `vector`).
  • mode: fast | high_recall (default);
  • index: hnsw (default) | ivf | ivf_pq;
  • nprobe (1-256) applies to ivf / ivf_pq;
  • refine_k_factor (1-64) applies to ivf_pq with raw vectors kept;
  • engine "bruteforce" forces an exact scan.
  • k above the server ceiling (default 4096) is a 400.
  • `filter` is a strict-equality metadata map ({field: value});
  • `filter_expr` is the typed operator filter (e.g. {"tag": {"$eq": "a"}}) and cannot be combined with a non-empty `filter`;
  • `require_complete: true` turns an underfilled filtered answer into a 422.
FieldTypeRequired
dimintegerRequired
embedderstringOptional
filterobjectOptional
filter_exprobjectOptional
indexstringOptional
kintegerRequired
metricstringOptional
modestringOptional
nprobeintegerOptional
querynumber[]Required
Fields in query
FieldTypeRequired
querynumberOptional
FieldTypeRequired
refine_k_factorintegerOptional
require_completebooleanOptional

Read the result

Each hit contains a vector ID and score. Interpret the score using the requested metric and use the ID to retrieve source data. A requested k is a limit, not a guarantee that enough matching records exist.

Response statuses

HTTP status reference
StatusWhat to do
200OK
400Correct the request before retrying.
401Check the credential and Authorization header.
402Check feature access or available credits.
403Check tenant access, roles and permissions.
408Reduce query work or adjust the timeout.
409Resolve the conflict before retrying.
413Split or reduce the request body.
415Send the required Content-Type.
422Correct the values or unsupported combination.
429Honor Retry-After when present; back off.
499The client cancelled the request.
500Check the outcome before retrying a write.
501Check deployment support for this operation.
503Honor Retry-After when present; check write outcomes.
ยฉ 2026 Silicoyn Technologies Pvt Ltd