milvus-logo
LFAI
< Docs
  • RESTful
    • v2
      • Index (v2)

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": 200,
    "data": {}
}

Request

Parameters

  • Header parameters

    ParameterDescription
    Request-Timeoutinteger
    The timeout duration for this operation.
    Setting this to None indicates that this operation timeouts when any response arrives or any error occurs.
    Authorizationstring
    The authentication token.
  • No query parameters required

  • No path parameters required

Request Body

{
    "dbName": "string",
    "collectionName": "string",
    "indexParams": [
        {
            "metricType": "string",
            "fieldName": "string",
            "indexName": "string",
            "indexConfig": {
                "index_type": "string",
                "M": "integer",
                "efConstruction": "integer",
                "nlist": "integer"
            }
        }
    ]
}
ParameterDescription
dbNamestring
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.
indexParamsarray
The parameters that apply to the index-building process.
indexParams[]object
indexParams[].metricTypestring
The similarity metric type used to build the index.
The value defaults to COSINE
indexParams[].fieldNamestring
The name of the target field on which an index is to be created.
indexParams[].indexNamestring
The name of the index to create, the value defaults to the target field name.
indexParams[].indexConfigobject
The index type and related settings. For details, refer to Vector Indexes.
indexParams[].indexConfig.index_typestring
The type of the index to create
indexParams[].indexConfig.Minteger
The maximum degree of the node and applies only when index_type is set to HNSW.
indexParams[].indexConfig.efConstructioninteger
The search scope. This applies only when index_type is set to HNSW
indexParams[].indexConfig.nlistinteger
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.

PropertyDescription
codeinteger
Indicates whether the request succeeds.
  • 200: The request succeeds.
  • Others: Some error occurs.
dataobject
messagestring
Indicates the possible reason for the reported error.
Feedback

Was this page helpful?