Skip to content

Index Management

The vector database supports different types of indexes for optimizing vector search operations. Each collection can have separate indexes for dense vectors, sparse vectors, and text search.

Create Dense Vector Index

Creates an index for dense vector search using approximate nearest neighbor (ANN) algorithms.

Endpoint: POST /vectordb/collections/{collection_id}/indexes/dense

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection to create an index for.

Request Body:

{
"name": "index_name",
"distance_metric_type": "cosine",
"quantization": {
"type": "auto",
"properties": {
"sample_threshold": 100
}
},
"index": {
"type": "hnsw",
"properties": {
"num_layers": 7,
"max_cache_size": 1000,
"ef_construction": 512,
"ef_search": 256,
"neighbors_count": 32,
"level_0_neighbors_count": 64
}
}
}

Request Parameters:

ParameterTypeRequiredDescription
namestringYesName of the index.
distance_metric_typestringYesDistance metric to use: “cosine”, “euclidean”, or “dot_product”.
quantizationobjectYesConfiguration for vector quantization.
quantization.typestringYesType of quantization: “auto” or “scalar”.
quantization.propertiesobjectYesProperties specific to the quantization type.
quantization.properties.sample_thresholdintegerYes (if auto)Number of vectors to sample for automatic quantization.
quantization.properties.data_typestringYes (if scalar)Data type for scalar quantization: “binary”, “quaternay”, “octal”, “u8”, “f16”, or “f32”.
quantization.properties.rangeobjectYes (if scalar)Value range for scalar quantization.
indexobjectYesConfiguration for index algorithm.
index.typestringYesType of index algorithm. Currently only “hnsw” is supported.
index.propertiesobjectYesProperties specific to the index algorithm.
index.properties.num_layersintegerNoNumber of layers in the HNSW graph.
index.properties.max_cache_sizeintegerNoMaximum number of elements in the cache.
index.properties.ef_constructionintegerNoSize of the dynamic candidate list during index construction.
index.properties.ef_searchintegerNoSize of the dynamic candidate list during search.
index.properties.neighbors_countintegerNoNumber of established connections per node.
index.properties.level_0_neighbors_countintegerNoNumber of connections at the ground layer.

Response:

{}

Status Codes:

CodeDescription
201Created. Index created successfully.
400Bad Request. Invalid index parameters.
404Not Found. Collection not found.
409Conflict. Index already exists for this collection.
500Server Error. Failed to create index.

Create Sparse Vector Index

Creates an index for sparse vector search.

Endpoint: POST /vectordb/collections/{collection_id}/indexes/sparse

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection to create an index for.

Request Body:

{
"name": "index_name",
"quantization": 64,
"sample_threshold": 1000
}

Request Parameters:

ParameterTypeRequiredDescription
namestringYesName of the index.
quantizationintegerYesQuantization bit value. Allowed values: 16, 32, 64, 128, or 256.
sample_thresholdintegerYesNumber of vectors to sample for calibrating the index.

Response:

{}

Status Codes:

CodeDescription
201Created. Index created successfully.
400Bad Request. Invalid index parameters.
404Not Found. Collection not found.
409Conflict. Index already exists for this collection.
500Server Error. Failed to create index.

Create TF-IDF Index

Creates an index for text search using TF-IDF/BM25.

Endpoint: POST /vectordb/collections/{collection_id}/indexes/tf-idf

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection to create an index for.

Request Body:

{
"name": "index_name",
"sample_threshold": 1000,
"k1": 1.2,
"b": 0.75
}

Request Parameters:

ParameterTypeRequiredDescription
namestringYesName of the index.
sample_thresholdintegerYesNumber of documents to sample for calibrating the index.
k1floatYesBM25 k1 parameter that controls term frequency saturation. Typical values range from 1.2 to 2.0.
bfloatYesBM25 b parameter that controls document length normalization. Typical value is 0.75.

Response:

{}

Status Codes:

CodeDescription
201Created. Index created successfully.
400Bad Request. Invalid index parameters.
404Not Found. Collection not found.
409Conflict. Index already exists for this collection.
500Server Error. Failed to create index.

Get Index

Retrieves information about the indexes defined for a collection.

Endpoint: GET /vectordb/collections/{collection_id}/indexes

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection to get indexes for.

Response:

{
"dense": {
"name": "dense_index_name",
"distance_metric_type": "cosine",
"quantization": {
"type": "auto",
"properties": {
"sample_threshold": 100
}
},
"index": {
"type": "hnsw",
"properties": {
"num_layers": 7,
"max_cache_size": 1000,
"ef_construction": 512,
"ef_search": 256,
"neighbors_count": 32,
"level_0_neighbors_count": 64
}
}
},
"sparse": {
"name": "sparse_index_name",
"quantization": 64,
"sample_threshold": 1000
},
"tf-idf": {
"name": "tf_idf_index_name",
"sample_threshold": 1000,
"k1": 1.2,
"b": 0.75
}
}

Status Codes:

CodeDescription
200Success. Index information returned.
404Not Found. Collection not found.
500Server Error. Failed to retrieve index information.

Delete Index

Deletes an index from a collection.

Endpoint: DELETE /vectordb/collections/{collection_id}/indexes/{index_type}

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection containing the index.
index_typestringYesType of index to delete: “dense”, “sparse”, or “tf_idf”.

Status Codes:

CodeDescription
204No Content. Index deleted successfully.
400Bad Request. Invalid index type.
404Not Found. Collection or index not found.
500Server Error. Failed to delete index.