A list of indices in MongoDB?

前端 未结 6 948
离开以前
离开以前 2020-12-07 23:57

Is there a way to see a list of indices on a collection in mongodb in shell? i read through http://www.mongodb.org/display/DOCS/Indexes but i dont see anything

6条回答
  •  独厮守ぢ
    2020-12-08 00:22

    If you want to list all indexes:

    db.getCollectionNames().forEach(function(collection) {
       indexes = db.getCollection(collection).getIndexes();
       print("Indexes for " + collection + ":");
       printjson(indexes);
    });
    

提交回复
热议问题