milvus-logo
LFAI
Home
  • User Guide

Drop an Index

This topic describes how to drop an index in Milvus. Before dropping an index, make sure to release it first.

Dropping an index irreversibly removes all corresponding index files.

When interacting with Milvus using Python code, you have the flexibility to choose between PyMilvus and MilvusClient (new). For more information, refer to Python SDK.

Drop the only index in a collection:

from pymilvus import Collection
collection = Collection("book")      # Get an existing collection.
collection.drop_index()
await milvusClient.dropIndex({
  collection_name: "book",
});
err = milvusClient.DropIndex(
  context.Background(),     // ctx
  "book",                   // CollectionName
  "book_intro",             // fieldName
)
if err != nil {
  log.Fatal("fail to drop index:", err.Error())
}
milvusClient.dropIndex(
  DropIndexParam.newBuilder()
    .withCollectionName("book")
    .withFieldName("book_intro")
    .build()
);
delete index -c book
curl -X 'DELETE' \
  'http://localhost:9091/api/v1/index' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "collection_name": "book",
    "field_name": "book_intro"
  }'
Parameter Description
collection_name Name of the collection to drop index from.
Parameter Description
ctx Context to control API invocation process.
CollectionName Name of the collection to drop index on.
fieldName Name of the vector field to drop index on.
Parameter Description
CollectionName Name of the collection to drop index on.
FieldName Name of the vector field to drop index on.

If a collection contains two or more indexes, specify the name of the index to delete it:

from pymilvus import Collection
collection = Collection("book")
collection.drop_index(index_name='book_intro')
await milvusClient.dropIndex({
  collection_name: "book",
  index_name: "book_intro"
});
milvusClient.dropIndex(
  DropIndexParam.newBuilder()
    .withCollectionName("book")
    .withIndexName("book_intro")
    .build()
);

What's next