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.

Parameters

Returns

Promise<QueryResponse>, whose results is:
  • One number[] query vector: QueryResultItem[], one item per neighbor.
  • Two or more query vectors (number[][] or Float32Array): QueryResultItem[][], one inner array per query vector.
A query with exactly one vector always returns single results, even when it’s sent as a batch or through the binary path. QueryResponse.results is typed QueryResultItem[] | QueryResultItem[][]. Since the call shape decides which one you get, narrow it with a cast: response.results as QueryResultItem[] for one vector, or as QueryResultItem[][] for a batch.

Result fields

query() never returns vector or contents, even when they’re listed in include. To read them, pass the result IDs to get().

Exceptions

  • Neither queryVectors nor queryContents is passed, or a Float32Array is passed without dimension. Thrown before any request is sent.
  • The service rejects the query (HTTP 400/422): 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 indexKey or apiKey is invalid (HTTP 401).
The service returns 5xx.
See Errors for the full hierarchy.

Example Usage

Single vector

Batch of vectors

Float32Array

Text, embedded by the service

Hybrid (BM25 + vector)

The index needs at least one full-text field, set with textFields or { fullText: true } in createIndex().

Filters and search options