milvus-logo

createIndex()

This method creates an index on a vector field. Note that the index building process is an asynchronous.

Invocation

new milvusClient(MILUVS_ADDRESS).collectionManager.createIndex(CreateIndexReq);

Parameters

CreateIndexReq

ParameterDescriptionTypeRequired
collection_nameCollection nameStringTrue
field_nameName of the field to create index onStringTrue
index_nameName of the index to createStringFalse
extra_paramsExtra index parameters (see the table below)IndexParamsFalse
timeoutAn optional duration of time in millisecond to allow for the RPC. Default is undefinedNumberFalse

IndexParams

ParameterDescriptionTypeRequired
index_typeIndex typeStringTrue
metric_typeMetric typeStringTrue
paramsIndex parametersJsonTrue

Example

new milvusClient(MILUVS_ADDRESS).indexManager.createIndex({
  collection_name: "my_collection",
  field_name: "vector_01",
  index_name: "index_name",
  extra_params: {
    index_type: "IVF_FLAT",
    metric_type: "IP",
    params: JSON.stringify({ nlist: 10 }),
  },
});

Return

// createIndex return
{ error_code: 'Success', reason: '' }