getIndexes() command - View JSON indexes for a collection command
Returns index information that identifies and describes the existing indexes for a collection.
Syntax diagram
Command parameters
- filter
- This optional parameter specifies the selection criteria for indexes.
The options are as follows:
- ID
- Get details for the index with the specified identifier.
- key
- Get details for indexes with the specified attribute.
- name
- Get details for the index with the specified name.
Example
View a list of all indexes and type
markers in the specified namespace:
db.books.getIndexes()
Sample output is as follows:[{"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}]
Example 2: View a list of all indexes and type
markers in the specified namespace:
db.books.getIndexes({"name": "_id_"})
Sample output is as follows:[{"v":0,"_id":57,"key":{"_id_":1},"ns":"TEST.books","name":"_id_","unique":true}]