Use this file to discover all available pages before exploring further.
Searches for nearest neighbors in the encrypted index using vector similarity search. Supports both single vector queries and batch queries with multiple vectors, as well as content-based search.
async query({ queryVectors?: number[] | number[][] | Float32Array, // optional, required if `queryContents` not provided queryContents?: string, // optional, required if `queryVectors` not provided topK?: number, // optional, default: 100 nProbes?: number, // optional, default: undefined (auto) filters?: FilterExpression, // optional, default: {} include?: string[], // optional, default: [] (only `id` is returned) greedy?: boolean, // optional, default: false dimension?: number // optional, required when queryVectors is Float32Array}): Promise<QueryResponse>
(Optional) Metadata filters to apply to the search (no filtering when undefined)
include
string[]
undefined (server default: [] — only id is returned)
(Optional) Fields to include: "distance", "metadata", "vector", "contents"
greedy
boolean
false
(Optional) Use faster approximate search
dimension
number
-
(Optional) Required when queryVectors is a Float32Array. Specifies vector dimensionality so the SDK can reshape the flat typed array.
Passing a Float32Array as queryVectors uses an optimized binary transfer format for better performance. When using Float32Array, the dimension parameter is required so the SDK can correctly reshape the flat array into individual query vectors.
// Search by text content (requires embedding model configured on index)try { const contentResults = await index.query({ queryContents: "machine learning tutorial", // content to embed and search topK: 10, // return top 10 results include: ['distance', 'metadata'] // include defaults to [] (only `id`); request distance and metadata }); console.log('Content-based search results:'); contentResults.results.forEach((item, i) => { console.log(`${i + 1}. ${item.id}: ${item.metadata?.title}`); console.log(` Distance: ${item.distance}`); });} catch (error: any) { console.error('Content search failed:', error.message); // May fail if no embedding model is configured for the index}