Index()

This is the constructor method to build an index on the specified field with the specified index parameters.

Invocation

Index(collection, field_name, index_params, **kwargs)

Parameters

ParameterDescriptionTypeRequired
collectionName of the collectionStringTrue
field_nameName of the field to build index onStringTrue
index_paramsMilvus Connection used to create the collectionDictTrue

Return

A new index object created with the specified parameters.

Properties

PropertyDescriptionType
paramsIndex parametersDict
collection_nameName of the collectionString
field_nameName of the indexed fieldString

Example

from pymilvus import Index
index_params = {"index_type": "IVF_FLAT", "metric_type": "L2", "params": {"nlist": 1024}}
index = Index("book", "book_intro", index_params)

drop()

This method drops the index and its corresponding index file in the collection.

Invocation

drop(timeout=None, **kwargs)

Parameters

ParameterDescriptionTypeRequired
timeoutAn optional duration of time in seconds to allow for the RPC. If it is set to None, the client keeps waiting until the server responds or error occurs.FloatFalse

Return

No return.

Raises

  • IndexNotExistException: error if the index does not exist.

Example

from pymilvus import Collection
collection = Collection("book")      # Get an existing collection.
collection.drop_index()