> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Manage Indexes in Data Explorer

You can use the Data Explorer to manage indexes on your collections.

## Required Roles

To [create](https://www.mongodb.com/docs/cloud-manager/data-explorer/indexes.md#std-label-de-create-an-index) or [drop indexes](https://www.mongodb.com/docs/cloud-manager/data-explorer/indexes.md#std-label-de-drop-an-index), you must have access provided by at least one of the following roles:

- [`Project Owner`](https://www.mongodb.com/docs/cloud-manager/reference/user-roles.md#mongodb-authrole-Project-Owner) or [`Organization Owner`](https://www.mongodb.com/docs/cloud-manager/reference/user-roles.md#mongodb-authrole-Organization-Owner)

- [`Project Data Access Admin`](https://www.mongodb.com/docs/cloud-manager/reference/user-roles.md#mongodb-authrole-Project-Data-Access-Admin)

## Considerations

By default, you can have up to three concurrent non-rolling index builds. To learn more, see [Maximum Concurrent Index Builds.](https://www.mongodb.com/docs/manual/core/index-creation/#maximum-concurrent-index-builds)

If you select to build indexes in a rolling fashion, you must ensure the following:

- Request rolling index builds and non-rolling index builds sequentially and not simultaneously. Wait for a currently executing index build to complete before you request another index build.

- If you need to request multiple rolling index builds, wait for the currently executing rolling index build to complete before you request another rolling index build.

To track rolling index builds, see the [Activity Feed.](https://www.mongodb.com/docs/cloud-manager/tutorial/manage-alerts-and-events.md#std-label-get-activity-feed)

For aborted rolling index builds, you must run [`listIndexes`](https://www.mongodb.com/docs/manual/reference/command/listIndexes.md#mongodb-dbcommand-dbcmd.listIndexes) on each node to verify that the cancelled index no longer exists. Otherwise, the cluster might remain in an inconsistent state.

**Warning:**

Due to critical issue [SERVER-68925](https://jira.mongodb.org/browse/SERVER-68925), Cloud Manager deployments using certain [versions](https://www.mongodb.com/docs/cloud-manager/release-notes/mongodb-agent.md#std-label-11.13.0.7438) of the MongoDB Agent should not perform [automated rolling index builds](https://www.mongodb.com/docs/cloud-manager/data-explorer/indexes/#optional-build-indexes-with-rolling-builds) on clusters running the following MongoDB versions:

- MongoDB 4.2.19-4.2.22

- MongoDB 4.4.13-4.4.16

- MongoDB 5.0.6-5.0.11

- MongoDB 6.0.0-6.0.1

You can continue to perform [manual rolling index builds](https://www.mongodb.com/docs/manual/tutorial/build-indexes-on-replica-sets.md#std-label-index-build-on-replica-sets) safely on your clusters. To perform automated rolling index builds safely, upgrade the MongoDB Agent to [12.4.0.7703](https://www.mongodb.com/docs/cloud-manager/release-notes/mongodb-agent.md#std-label-12.4.0.7703) or later or upgrade your clusters to:

- MongoDB 4.2.23 or later

- MongoDB 4.4.17 or later

- MongoDB 5.0.12 or later

- MongoDB 6.0.2 or later

**Important:**

Rolling index builds succeed only when they meet certain conditions. To ensure your index build succeeds, avoid the following design patterns that commonly trigger a restart loop:

- Index key exceeds the [index key limit](https://www.mongodb.com/docs/manual/reference/limits/#mongodb-limit-Index-Key-Limit)

- [Index name](https://www.mongodb.com/docs/manual/indexes.md#std-label-index-names) already exists

- Index on [more than one array field](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-multikey.md#std-label-compound_multikey_indexes)

- Index on collection that has the [maximum number of text indexes](https://www.mongodb.com/docs/manual/reference/limits.md#mongodb-limit-Number-of-Indexes-per-Collection)

- Text index on collection that has the [maximum number of text indexes](https://www.mongodb.com/docs/manual/core/index-text/#one-text-index-per-collection)

Building an index in a rolling fashion reduces the resiliency of your cluster and increases index build times. We only recommend using rolling index builds when regular index builds do not meet your needs.

**Note:**

Data Explorer doesn't support building indexes in a rolling fashion for standalone deployments.

Building indexes in a rolling fashion reduces the performance impact of building indexes on [replica sets](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-replica-set) and [sharded clusters](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-sharded-cluster). To maintain cluster availability, Cloud Manager removes one node from the cluster at a time starting with a [secondary.](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-secondary)

After you build an index in a rolling fashion, if your MongoDB database runs with an [`FCV`](https://www.mongodb.com/docs/manual/reference/command/setFeatureCompatibilityVersion.md#mongodb-dbcommand-dbcmd.setFeatureCompatibilityVersion) less than `4.2`, [resync the head database](https://www.mongodb.com/docs/cloud-manager/tutorial/resync-backup.md) to ensure that the head database takes the new index into account.

Cloud Manager automatically cancels rolling index builds that don't succeed on all nodes. When a rolling index build completes on some nodes, but fails on others, Cloud Manager cancels the build and removes the index from any nodes that it was successfully built on.

In the event of a rolling index build cancellation, Cloud Manager generates an activity feed event and sends a notification email to the project owner with the following information:

- Name of the cluster on which the rolling index build failed

- Namespace on which the rolling index build failed

- Project that contains the cluster and namespace

- Organization that contains the project

- Link to the activity feed event

To learn more about rebuilding indexes, see [Build Indexes on Replica Sets.](https://www.mongodb.com/docs/manual/tutorial/build-indexes-on-replica-sets.md#std-label-index-build-on-replica-sets)

**Note:**

The following [index options](https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex.md#std-label-createIndex-options) are incompatible with building indexes in a rolling fashion:

- [unique](https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex/#options-for-all-index-types)

- [storageEngine](https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex/#options-for-all-index-types)

- [textIndexVersion](https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex/#options-for-text-indexes)

- [2dsphereIndexVersion](https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex.md#std-label-2d-index-options)

Cloud Manager ignores these options if you specify them in the Options pane.

## View Indexes

**Warning:**

The Data Explorer only shows Usage metrics for the primary node in your cluster. If your application primarily reads from secondary nodes, the Usage metrics do not accurately reflect index usage across your cluster.

For more comprehensive index usage statistics, run the [`$indexStats`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats.md#mongodb-pipeline-pipe.-indexStats) aggregation stage on each node in your cluster.

From the Collections tab, you can view index information for a collection. To view index information for a collection:

1. Select the database for the collection.

   The main panel and Namespaces on the left side list the collections in the database.

2. Select the collection on the left-hand side or in the main panel.

   The main panel displays the Find, Indexes, and Aggregation views.

3. Select the Indexes view.

   The indexes table lists the indexes and associated index information for the collection. Index information includes the index definition, the size, and the usage frequency.

   ![Screenshot highlighting index view in Data Explorer.](/images/data-explorer-indexes-view.png)

## Create an Index

**Tip:**

When you create indexes, keep the ratio of reads to writes on the target collection in mind. Indexes come with a performance cost, but are more than worth the cost for frequent queries on large data sets. To learn more about indexing strategies, see [Indexing Strategies.](https://www.mongodb.com/docs/manual/applications/indexes.md#std-label-manual-indexing-strategies)

To create an index for a collection through the Data Explorer:

1. Go to the Indexes tab.

   Click the collection you wish to index.

   Click the Indexes tab under the collection name.

2. Click Create Index.

   In the Create Index modal, enter the [`index key specification`](https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex.md#mongodb-method-db.collection.createIndex) document in the Fields box:

   ```json
   { <field1>: <index type>, ... }
   ```

   **Example:**

   To create a compound index on the fields `category` (ascending order) and `score` (descending order), specify the index specification document:

   ```json
   { category: 1, score: -1 }
   ```

   For more information on indexes, see [Indexes.](https://www.mongodb.com/docs/manual/indexes.md#std-label-indexes)

3. *(Optional)* Specify the [index options](https://www.mongodb.com/docs/manual/reference/method/db.collection.createIndex.md#std-label-createIndex-options).

   ```json
   { <option1>: <value1>, ... }
   ```

   **Example:**

   To set the `unique` option and a `name` for the new index, enter this document:

   ```json
   { unique: true, name: "myUniqueIndex" }
   ```

4. *(Optional)* Set the [Collation](https://www.mongodb.com/docs/manual/reference/collation.md#std-label-collation-document-fields) options.

   Use collation to specify language-specific rules for string comparison, such as rules for lettercase and accent marks. The [collation document](https://www.mongodb.com/docs/manual/reference/collation.md#std-label-collation-document-fields) contains a `locale` field which indicates the [ICU Locale code](http://userguide.icu-project.org/locale), and may contain other fields to define collation behavior.

   **Example:**

   The following collation option document specifies a locale value of `fr` for a French language collation:

   ```json
   { "locale": "fr" }
   ```

   To review the list of locales that MongoDB collation supports, see the [list of languages and locales](https://www.mongodb.com/docs/manual/reference/collation-locales-defaults.md#std-label-collation-languages-locales). To learn more about collation options, including which are enabled by default for each locale, see [Collation](https://www.mongodb.com/docs/manual/reference/collation.md#std-label-collation-document-fields) in the MongoDB manual.

5. Click Create.

6. Confirm your index.

   The Confirm Operation modal appears.

   - If your index creation looks correct, click Confirm. This closes the modal and create the index.

   - If your index creation looks incorrect, click Cancel. This closes the modal without creating the index.

## Drop an Index

To drop an index from a collection through the Data
Explorer:

1. Go to the Indexes tab.

   Select the collection whose index you wish to drop, and go to the Indexes tab.

2. Click the Drop Index button for the index to drop.

3. Confirm action.

   Confirm by typing the name of the index, and click Drop.

**Note:**

You cannot delete the `_id` index.
