Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
queryVectors | number[] | number[][] | - | Single vector [0.1, 0.2] or batch vectors [[0.1, 0.2], [0.3, 0.4]] |
queryContents | string | - | (Optional) Text content to embed and search (alternative to queryVectors) |
topK | number | undefined (server default: 100) | (Optional) Number of nearest neighbors to return per query |
nProbes | number | undefined (auto) | (Optional) Number of cluster centers to search (higher = better recall). Auto-determined when undefined. |
filters | object | undefined | (Optional) Metadata filters to apply to the search (no filtering when undefined) |
include | string[] | undefined (server default: ["distance", "metadata"]) | (Optional) Fields to include: "distance", "metadata", "vector", "contents" |
greedy | boolean | false | (Optional) Use faster approximate search |
Returns
Promise<QueryResponse>: A Promise that resolves to search results. The response format depends on the query type:
- Single vector query:
resultsis a flat array ofQueryResultItem[] - Batch query:
resultsis a nested array ofQueryResultItem[][](one array per input vector)
Exceptions
Error
Error
- Throws if the API request fails due to network connectivity issues.
- Throws if authentication fails (invalid API key).
- Throws if the encryption key is invalid for the specified index.
- Throws if there are internal server errors during the search.
Validation Errors
Validation Errors
- Throws if neither queryVectors nor queryContents is provided.
- Throws if vector dimensions don’t match the index configuration.
- Throws if parameter values are out of valid ranges.
- Throws if the
includeparameter contains invalid field names.