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
- Pair query indices and valuesDescribe the populated features of the query.
- Search with optional metadata filtersCompare against stored sparse vectors.
- Inspect similar vector IDsRead each returned similarity score.
Before you start
Use your database bearer token.
Store sparse vectors in the collection before searching. The example uses demo_vectors.
Path parameters
| Field | Type | Required |
|---|---|---|
tenant | string | Required |
table | string | Required |
Headers
| Field | Type | Required | Description |
|---|---|---|---|
x-oc-db-user | string | Optional | Acting database user (role, grant and row-policy checks). Send with x-oc-db-key. |
x-oc-db-key | string | Optional | API 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.
| Field | Type | Required |
|---|---|---|
dim | integer | Required |
filter | object | Optional |
filter_expr | object | Optional |
k | integer | Required |
query_indices | integer[] | Required |
Fields in query_indices
| Field | Type | Required |
|---|---|---|
query_indices | integer | Optional |
| Field | Type | Required |
|---|---|---|
query_values | number[] | Required |
Fields in query_values
| Field | Type | Required |
|---|---|---|
query_values | number | Optional |
| Field | Type | Required |
|---|---|---|
require_complete | boolean | Optional |
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
| Status | What to do |
|---|---|
| 200 | OK |
| 400 | Correct the request before retrying. |
| 401 | Check the credential and Authorization header. |
| 402 | Check feature access or available credits. |
| 403 | Check tenant access, roles and permissions. |
| 408 | Reduce query work or adjust the timeout. |
| 413 | Split or reduce the request body. |
| 415 | Send the required Content-Type. |
| 422 | Correct the values or unsupported combination. |
| 429 | Honor Retry-After when present; back off. |
| 499 | The client cancelled the request. |
| 500 | Check the outcome before retrying a write. |
| 501 | Check deployment support for this operation. |
| 503 | Honor Retry-After when present; check write outcomes. |