OriginChainDB
Database endpoints

Search sparse vectors

Returns the k stored sparse vectors most similar to a sparse query vector, optionally filtered by metadata.

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

Compare weighted features in sparse vectorsQuery positions and values must use the same dimension as stored data.
  1. Pair query indices and valuesDescribe the populated features of the query.
  2. Search with optional metadata filtersCompare against stored sparse vectors.
  3. Inspect similar vector IDsRead each returned similarity score.

Before you start

Use your database bearer token.

Connection setup

Store sparse vectors in the collection before searching. The example uses demo_vectors.

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
  • `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
filterobjectOptional
filter_exprobjectOptional
kintegerRequired
query_indicesinteger[]Required
Fields in query_indices
FieldTypeRequired
query_indicesintegerOptional
FieldTypeRequired
query_valuesnumber[]Required
Fields in query_values
FieldTypeRequired
query_valuesnumberOptional
FieldTypeRequired
require_completebooleanOptional

Read the result

Each hit identifies a stored sparse vector and its similarity score. Pair query indices with query values and keep the dimension consistent with the stored data.

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.
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