Vector Search API
REST API endpoints for vector index management and similarity search.
Vector Index Management
/_api/database/:db/vector/:collection
Create a new vector index for similarity search on an embedding field.
Request Body
| Field | Type | Description | Required |
|---|---|---|---|
| name | string | Unique name for the vector index. | Yes |
| field | string | Document field containing embedding vectors. | Yes |
| dimension | integer | Vector dimension (e.g., 1536 for OpenAI embeddings). | Yes |
| metric | string |
Distance metric: cosine (default), euclidean, dot.
|
No |
| quantization | string |
Compression method: none (default), scalar (4x memory reduction).
|
No |
Example Request
Response
/_api/database/:db/vector/:collection
List all vector indexes for a collection.
Response
/_api/database/:db/vector/:collection/:name
Delete a vector index.
Path Parameters
| Parameter | Description |
|---|---|
| db | Database name |
| collection | Collection name |
| name | Vector index name to delete |
Response
Vector Quantization
/_api/database/:db/vector/:collection/:index/quantize
Apply scalar quantization to an existing vector index for 4x memory reduction. Vectors are compressed from f32 (4 bytes/dim) to u8 (1 byte/dim).
Path Parameters
| Parameter | Description |
|---|---|
| db | Database name |
| collection | Collection name |
| index | Vector index name to quantize |
Example Request
Response
Asymmetric Search
After quantization, searches use asymmetric distance computation: query vectors remain at full f32 precision while database vectors are stored as u8. This maintains ~98% recall while achieving 4x compression.
/_api/database/:db/vector/:collection/:index/dequantize
Remove quantization from a vector index, reverting to full f32 precision search.
Example Request
Response
Vector Similarity Search
/_api/database/:db/vector/:collection/:index/search
Perform a similarity search to find the nearest vectors to a query vector.
Path Parameters
| Parameter | Description |
|---|---|
| db | Database name |
| collection | Collection containing documents with vectors |
| index | Name of the vector index to search |
Request Body
| Field | Type | Description | Required |
|---|---|---|---|
| vector | array[float] | Query vector (must match index dimension). | Yes |
| limit | integer | Maximum number of results to return. Default: 10. | No |
| ef_search | integer | HNSW search quality parameter. Higher values improve recall but increase latency. Only used when HNSW is active (>10K vectors). Default: max(limit*2, 40). | No |
Example Request
Response
Score Interpretation
For cosine metric, scores range from -1 to 1 (higher = more similar). For euclidean, scores are distances (lower = more similar). For dot product, higher scores indicate more similarity.
Hybrid Search (Vector + Fulltext)
/_api/database/:db/hybrid/:collection/search
Combine vector similarity with fulltext search for improved RAG results. Documents matching both sources rank highest.
Path Parameters
| Parameter | Description |
|---|---|
| db | Database name |
| collection | Collection to search |
Request Body
| Field | Type | Description | Required |
|---|---|---|---|
| vector | array[float] | Query embedding vector. | Yes |
| text_query | string | Text query for fulltext search. | Yes |
| vector_index | string | Name of the vector index to use. | Yes |
| fulltext_field | string | Document field to search with fulltext. | Yes |
| vector_weight | float | Weight for vector scores (0-1). Default: 0.5. | No |
| text_weight | float | Weight for fulltext scores (0-1). Default: 0.5. | No |
| limit | integer | Maximum results to return. Default: 10. | No |
| fusion | string | Score fusion method: weighted (default) or rrf. |
No |
Example Request
Response
Score Interpretation
score is the combined score (0-1). sources indicates which searches matched. Documents in both vector and fulltext results rank highest.
Complete Example
A full workflow for setting up and using vector search: