OPTIONS

Remove Indexes

To remove an index from a collection use the dropIndex() method and the following procedure. If you simply need to rebuild indexes you can use the process described in the Rebuild Indexes document.

See also

Indexing Tutorials and Index Concepts for more information about indexes and indexing operations in MongoDB.

Remove a Specific Index

To remove an index, use the db.collection.dropIndex() method.

For example, the following operation removes an ascending index on the tax-id field in the accounts collection:

db.accounts.dropIndex( { "tax-id": 1 } )

The operation returns a document with the status of the operation:

{ "nIndexesWas" : 3, "ok" : 1 }

Where the value of nIndexesWas reflects the number of indexes before removing this index.

For text indexes, pass the index name to the db.collection.dropIndex() method. See Use the Index Name to Drop a text Index for details.

Remove All Indexes

You can also use the db.collection.dropIndexes() to remove all indexes, except for the _id index from a collection.

These shell helpers provide wrappers around the dropIndexes database command. Your client library may have a different or additional interface for these operations.