getIndexes() command - View JSON indexes for all collections

Prints index information for all the collections in this JSON namespace.

Syntax diagram

Read syntax diagramSkip visual syntax diagramdb.collection. getIndexes(filter )

Command arguments

filter
This optional argument specifies the selection criteria for indexes. The query options are as follows:
ns
Get details for the indexes on this schema.collection.
id
Get details for the index with this identifier.
key
Get details for indexes with the specified attribute.
name
Get details for the index with this name.
schema
Get details for the indexes with this schema.

Example

Example 1: View a list of all indexes and type markers in this namespace
db.getIndexes())
Sample output:
[{"v":0,"_id":57,"key":{"_id_":1},"ns":"TEST.books","name":"_id_","unique":true},
{"v":0,"_id":63,"key":{"author":1},"ns":"TEST.books","name":"books_xauthor","unique":false},
[{"v":0,"_id":65,"key":{"_id_":1},"ns":"TEST.dvds","name":"_id_","unique":true},
{"v":0,"_id":66,"key":{"title":1},"ns":"TEST.dvds","name":"dvds_xtitle","unique":false}]
Example 2
db.getIndexes({"name": "_id_"})
Sample output:
[{"v":0,"_id":57,"key":{"_id_":1},"ns":"TEST.books","name":"_id_","unique":true},
{"v":0,"_id":65,"key":{"_id_":1},"ns":"TEST.dvds","name":"_id_","unique":true}]