Method Overloads
Thequery
method supports two calling patterns:
Pattern 1: Individual Parameters
Pattern 2: Request Object
Parameters
Individual Parameters Pattern
Parameter | Type | Default | Description |
---|---|---|---|
queryVector | number[] | number[][] | - | Single vector (1D array) or multiple vectors (2D array) to search for |
topK | number | 100 | (Optional) Number of nearest neighbors to return for each query |
nProbes | number | 1 | (Optional) Number of lists to probe during the query (affects accuracy vs speed tradeoff) |
greedy | boolean | false | (Optional) Whether to use greedy search algorithm |
filters | object | {} | (Optional) Metadata filters to apply to the search |
include | string[] | ["distance", "metadata"] | (Optional) Fields to include in results: "distance" , "metadata" , "vector" , "contents" |
Request Object Pattern
Parameter | Type | Description |
---|---|---|
request | QueryRequest | Complete query request object with all parameters |
Returns
Promise<QueryResponse>
: A Promise that resolves to search results. The response format depends on whether a single vector or multiple vectors were queried:
- Single vector query:
results
is a flat array ofQueryResultItem[]
- Batch query:
results
is 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 no query vector is provided.
- Throws if vector dimensions don’t match the index configuration.
- Throws if parameter values are out of valid ranges.
- Throws if the
include
parameter contains invalid field names.
Example Usage
Basic Single Vector Query
Advanced Single Query with Options
Batch Vector Query
Metadata Filtering
QueryResultItem Fields
Field | Type | Description |
---|---|---|
id | string | Unique identifier of the matching vector |
distance | number | Similarity distance (lower values indicate higher similarity) |
metadata | any | Associated metadata (included if "metadata" in include array) |
vector | number[] | The vector data (included if "vector" in include array) |
contents | string | The content data (included if "contents" in include array) |