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[][]orFloat32Array):QueryResultItem[][], one inner array per query vector.
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
CyborgDBValidationError
CyborgDBValidationError
- Neither
queryVectorsnorqueryContentsis passed, or aFloat32Arrayis passed withoutdimension. Thrown before any request is sent. - The service rejects the query (HTTP
400/422): wrong vector dimension,texton an index without full-text fields, or an out-of-rangealpha,rrfK, orwindowMult. Other numeric parameters aren’t range-checked.
CyborgDBAuthenticationError
CyborgDBAuthenticationError
The
indexKey or apiKey is invalid (HTTP 401).CyborgDBServiceError
CyborgDBServiceError
The service returns
5xx.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 withtextFields or { fullText: true } in createIndex().