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
- Prepare a compatible query vectorMatch the stored embeddings' dimension and metric.
- Search with optional filtersLimit candidates to the metadata you need.
- Read IDs and scoresUse each ID to retrieve the source data.
Before you start
Use your database bearer token.
Store dense vectors in the collection before searching it. The example uses demo_vectors; scores depend on your data and distance metric.
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
- 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.
| Field | Type | Required |
|---|---|---|
dim | integer | Required |
embedder | string | Optional |
filter | object | Optional |
filter_expr | object | Optional |
index | string | Optional |
k | integer | Required |
metric | string | Optional |
mode | string | Optional |
nprobe | integer | Optional |
query | number[] | Required |
Fields in query
| Field | Type | Required |
|---|---|---|
query | number | Optional |
| Field | Type | Required |
|---|---|---|
refine_k_factor | integer | Optional |
require_complete | boolean | Optional |
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
| 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. |
| 409 | Resolve the conflict before retrying. |
| 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. |