Skip to main content
POST
Query Vectors
Retrieve the nearest neighbors for a given query vector. Passing text alongside query_vectors turns this into a hybrid query that fuses BM25 full-text ranking with the vector ranking (see Full-Text and Hybrid Search). Adding filters on top composes with either form — including a three-way query (vector + BM25 + metadata); see Combining search legs.

Authentication

Required - API key via X-API-Key header:
Any valid credential is accepted — the root key or a per-user cdbk_ token. When RBAC is not enabled (CYBORGDB_SERVICE_ROOT_KEY unset), no header is required.

Request Body

Single Query Request

Batch Query Request

Semantic Search Request (with embedding model)

Hybrid queries accept fewer filters than pure vector queries. Filtering on a full_text or filterable: false field, or using $regex/$contains on a non-pattern field, works in a pure query but is rejected with 400 when text is set. To keep such a filter, run the query without text.

Response

Single Query Response

When query_vectors is a 1D array or query_contents is used:

Batch Query Response

When query_vectors is a 2D array (array of arrays):
The response format automatically matches the request format:
  • Single query → flat array of results
  • Batch query → nested array with results for each query

Hybrid Query Response

When text is set alongside query_vectors, each result carries a score (fused BM25 + vector relevance, higher = more relevant) instead of distance — a text-only match has no vector distance to report:

Metadata Filtering

Use MongoDB-style query operators:
Supported operators: $eq, $ne, $in, $nin, $exists, $gt, $gte, $lt, $lte, $regex, $contains, combined with $and, $or, $nor, $not Filtering works on any metadata field; the index’s metadata_schema only decides how a filter is resolved — fields marked filterable (the default) are answered from the inverted index, and $regex / $contains are answered from the regex dictionary on pattern fields. Anything else falls back to a post-filter over the decrypted metadata, which is correct but slower. Dates have no native type: store and filter them as epoch milliseconds.

Combining Search Legs

Vector similarity, BM25 full-text, and metadata filtering are independent legs that compose in one request: On a three-way query the filter is resolved once, before retrieval, and the surviving IDs constrain both the vector and BM25 legs — so both rankings are computed over the same filtered candidate set, then fused by RRF. A filter that matches nothing short-circuits to an empty result without running either leg. alpha still applies: 0 reduces the query to BM25 + metadata, 1 to vector + metadata, and either exact endpoint skips the dead leg’s retrieval entirely.
Any query with text set accepts only filters the metadata index can resolve exactly (see the Note above) — this includes the three-way form.

Exceptions

Invalid values (e.g. vector dimension mismatch with the index), or a hybrid-parameter violation — a filter disallowed on a hybrid (text) query (see the Note above), text on an index with no full_text field, a text_fields entry that is not a full_text field, a text knob (text_fields / text_field_weights / require_all_terms) without text, alpha outside [0, 1], rrf_k <= 0, or window_mult < 1
Authentication failed (invalid API key) or wrong index_key on SDK-supplied indexes — see error model
Index not found
Request body failed validation (missing/mistyped fields)
Internal server error
Embedding model unavailable (semantic search via query_contents)

Example Usage

Basic Query:
With Filters:
Semantic Search:
Hybrid Query (BM25 + Vector):
Three-Way Query (Vector + BM25 + Metadata):
Batch Query:
High Recall Query:
If embedding_model is configured for the index, you can use either query_vectors for direct vector search or query_contents for text-based semantic search.
Higher n_probes, rerank_mult, and greedy=true all increase recall but reduce query performance. Start with defaults and adjust based on your recall requirements.