DBAtlas · Database operations atlas

27 IndexNotFound: Index not found

MongoDB

What does it mean?

The referenced index was not found on the collection. Usually appears when trying to drop or rename a nonexistent index.

Why does it happen?

Giving a wrong index name or wrong key specification in a command such as dropIndex/hideIndex; the index having been dropped earlier; or the auto-generated index name differing from what was expected (MongoDB generates names like field_1_field2_-1).

How to fix it

List existing indexes and their exact names: db.my_collection.getIndexes(). Repeat the operation with the correct name or key document: db.my_collection.dropIndex({field: 1}) or db.my_collection.dropIndex('field_1'). Write drop scripts so they do not fail when the index is absent (with an existence check).

Open in DBAtlas →

More from this engine