MongoDB

Rebuild Indexes using Mongo shell

If you need to rebuild indexes for a collection you can use the db.collection.reIndex() method to rebuild all indexes on a collection in a single operation. This operation drops all indexes, including the _id index, and then rebuilds all indexes.

Example:-

 db.users.reIndex()  

Leave a comment