listIndexes

New in version 3.0.0.

Definition

  • listIndexes
  • Returns information about the indexes on the specified collection.Specifically, the command returns a document that containsinformation with which to create a cursor to the index information.Index information includes the keys and options used to create theindex. The mongo shell provides thedb.collection.getIndexes() helper.

The command has the following form:

  1. { "listIndexes": "<collection-name>" }

FieldTypeDescriptionlistIndexesstringThe name of the collection.

Required Access

The user executing the command requires either findprivileges on the system.indexes collection or thelistIndexes privilege action. At a minimum, thereadbuilt-in role providethe requisite permissions.

Behavior

Client Disconnection

Starting in MongoDB 4.2, if the client that issued the listIndexesdisconnects before the operation completes, MongoDB marksthe listIndexes for termination (i.e. killOp on theoperation).

Output

  • listIndexes.cursor
  • A document that contains information with which to create a cursorto index information. The cursor information includes the cursor id,the full namespace for the command, as well as the first batch ofresults. Index information includes the keys and options used tocreate the index. For information on the keys and index options, seedb.collection.createIndex().
  • listIndexes.ok
  • The return value for the command. A value of 1 indicatessuccess.