Skip to main content
Finds the nearest neighbors of one or more query vectors. With QueryContents, the service embeds the text first (the index needs an EmbeddingModel). With Text, the query becomes hybrid: BM25 full-text ranking is fused with the vector ranking.
input is either QueryParams (sent as JSON) or BinaryQueryParams (vectors sent as binary, faster for large batches).

Parameters

QueryParams

Optional scalar fields are pointers: leave them nil to use the service default.

BinaryQueryParams

The same fields as QueryParams, except:
  • QueryVectors [][]float32 replaces QueryVector and BatchQueryVectors.
  • There is no QueryContents.

Returns

*QueryResponse, whose Results holds exactly one of:
  • Results.ArrayOfQueryResultItem (*[]QueryResultItem): one query vector.
  • Results.ArrayOfArrayOfQueryResultItem (*[][]QueryResultItem): two or more query vectors.
A query with exactly one vector always returns single results, even when it’s sent as a batch or through the binary path.

Result fields

Query never returns vectors or contents, even when they’re listed in Include. To read them, pass the result IDs to Get.

Errors

  • Wraps ErrEmptyQueryVectors, ErrInconsistentDimension, or ErrUnsupportedQueryType. A BinaryQueryParams has no vectors or vectors of different lengths, or input is another type. Returned before any request is sent.
  • The service rejects the query (HTTP 400/422): no query input, wrong vector dimension, Text on an index without full-text fields, or an out-of-range Alpha, RrfK, or WindowMult. Other numeric parameters aren’t range-checked.
The apiKey is invalid (HTTP 401).
The service returns 5xx or can’t be reached.
See Errors.

Example Usage

Single vector

Batch of vectors

BinaryQueryParams

Text, embedded by the service

Hybrid (BM25 + vector)

The index needs at least one full-text field, set with TextFields or FullText in CreateIndex.

Filters and search options