- Reference >
mongo
Shell Methods >- Collection Methods >
- db.collection.getIndexes()
db.collection.getIndexes()¶
-
db.collection.
getIndexes
()¶ Returns an array that holds a list of documents that identify and describe the existing indexes on the collection. You must call the
db.collection.getIndexes()
on a collection. For example:Change
collection
to the name of the collection whose indexes you want to learn.The
db.collection.getIndexes()
items consist of the following fields:-
system.indexes.
v
¶ Holds the version of the index.
The index version depends on the version of
mongod
that created the index. Before version 2.0 of MongoDB, the this value was 0; versions 2.0 and later use version 1.
-
system.indexes.
key
¶ Contains a document holding the keys held in the index, and the order of the index. Indexes may be either descending or ascending order. A value of negative one (e.g.
-1
) indicates an index sorted in descending order while a positive value (e.g.1
) indicates an index sorted in an ascending order.
-
system.indexes.
ns
¶ The namespace context for the index.
-
system.indexes.
name
¶ A unique name for the index comprised of the field names and orders of all keys.
-