- Indexes >
- Indexing Tutorials >
- Index Management Tutorials >
- Remove Indexes
Remove Indexes¶
On this page
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.
Operations¶
To remove an index, use the db.collection.dropIndex()
method,
as in the following example:
This will remove the index on the "tax-id"
field in the accounts
collection. The shell provides the following document after completing
the operation:
Where the value of nIndexesWas
reflects the number of indexes
before removing this index. 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.