Searches the vector index for the nearest neighbors of a given query.
The HNSW index to search.
The query string to search for.
Optional
Optional parameters for the search.
The number of nearest neighbors to return.
A promise that resolves to an array of nearest neighbors, each with an id and distance.
If there's an error during the search process.
const index = await addEmbeddingVectorsToIndex(documentVectors);const results = await searchVectorIndex(index, 'example query');console.log(results); // [{id: 3, distance: 0.1}, {id: 7, distance: 0.2}, ...] Copy
const index = await addEmbeddingVectorsToIndex(documentVectors);const results = await searchVectorIndex(index, 'example query');console.log(results); // [{id: 3, distance: 0.1}, {id: 7, distance: 0.2}, ...]
Searches the vector index for the nearest neighbors of a given query.