db.collection.reIndex()
Reindex all mongodb collections
db.getCollectionNames().forEach(function(coll_name) { var coll = db.getCollection(coll_name); coll.reIndex(); });
References
https://docs.mongodb.com/manual/reference/method/db.collection.reIndex/#db-collection-reindex
https://stackoverflow.com/questions/12187225/command-to-reindex-all-mongodb-collections