Create Index
POST
http://${MILVUS_URI}/v2/vectordb/indexes/create
This creates a named index for a target field, which can either be a vector field or a scalar field.
Example
export MILVUS_URI="localhost:19530"
curl --location --request POST "http://${MILVUS_URI}/v2/vectordb/indexes/create" \
--header "Content-Type: application/json" \
--data-raw '{
"collectionName": "custom_setup_not_indexed",
"indexParams": [
{
"metricType": "L2",
"fieldName": "my_vector",
"indexName": "my_vector",
"indexConfig": {
"index_type": "IVF_FLAT",
"nlist": "1024"
}
}
]
}'
Possible response is similar to the following:
{
"code": 0,
"data": {}
}
Request
Parameters
Header parameters
Parameter Description Request-Timeout
integer
The timeout duration for this operation.
Setting this to None indicates that this operation timeouts when any response arrives or any error occurs.Authorization
string
The authentication token.No query parameters required
No path parameters required
Request Body
{
"dbName": "string",
"collectionName": "string",
"indexParams": [
{
"metricType": "string",
"fieldName": "string",
"indexName": "string",
"params": {
"index_type": "string",
"M": "integer",
"efConstruction": "integer",
"nlist": "integer"
}
}
]
}
Parameter | Description |
---|---|
dbName | string The name of the database to which the collection belongs. Setting this to a non-existing database results in an error. |
collectionName * | string The name of the target collection. Setting this to a non-existing collection results in an error. |
indexParams | array The parameters that apply to the index-building process. |
indexParams[] | object |
indexParams[].metricType | string The similarity metric type used to build the index. The value defaults to COSINE |
indexParams[].fieldName | string The name of the target field on which an index is to be created. |
indexParams[].indexName | string The name of the index to create, the value defaults to the target field name. |
indexParams[].params | object The index type and related settings. For details, refer to Vector Indexes. |
indexParams[].params.index_type | string The type of the index to create |
indexParams[].params.M | integer The maximum degree of the node and applies only when index_type is set to HNSW. |
indexParams[].params.efConstruction | integer The search scope. This applies only when index_type is set to HNSW |
indexParams[].params.nlist | integer The number of cluster units. This applies to IVF-related index types. |
Response
A Status object indicating whether this operation succeeds.
Response Bodies
- Response body if we process your request successfully
{
"code": "integer",
"data": {}
}
- Response body if we failed to process your request
{
"code": integer,
"message": string
}
Properties
The properties in the returned response are listed in the following table.
Property | Description |
---|---|
code | integer Indicates whether the request succeeds.
|
message | string Indicates the possible reason for the reported error. |
data | object |