Search Operations
The search endpoint allows you to find the nearest neighbors to a query vector using the HNSW index. Search uses a binary protocol for maximum performance.Search
Search for the k nearest neighbors to a query vector.Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
index_name | string | Yes | — | Name of the index to search |
k | integer | No | 10 | Number of nearest neighbors to return |
efs | integer | No | 64 | Search-time ef (controls recall vs. speed) |
Binary Request Body
The request body contains the query vector as float32 little-endian values:Response
The response is a JSON array of external IDs, ordered by similarity (nearest first):Example with curl
Example with Python
Search Parameters Explained
- k — The number of results to return. Higher values return more neighbors but take slightly longer. Typical values are 5-100.
- efs — The search-time ef parameter controls the trade-off between recall and speed. Higher values give better recall (more accurate results) but slower queries. The
efsparameter overrides theef_searchvalue set during index creation for this specific query.
Choosing efs
| efs Value | Use Case |
|---|---|
| 32-64 | Fast, approximate results; good for autocomplete or exploratory search |
| 64-128 | Balanced speed and recall; good for most production use cases |
| 128-512 | High recall; good for applications where accuracy is critical |
| 512+ | Maximum recall; use when you need the best possible results and can tolerate slower queries |