removeIndex() - Remove a JSON index command

Removes the specified index from a collection

Syntax diagram

Read syntax diagramSkip visual syntax diagramdb.collection. removeIndex(index_spec)

Command parameters

index_spec
This parameter specifies an index name or the JSON definition of the index that is to be removed.

Example

Example 1: Remove the mypriceidx index by referring to the index name:
db.books.removeIndex("mypriceidx")
Sample output is as follows:
Index <mypriceidx> was removed successfully.
Example 2: Remove an index by specifying the index characteristics.
db.books.removeIndex({"author": 1})
Sample output is as follows:
Index <books_xauthor> was removed successfully.