Docs Menu

Docs HomeAtlas CLI

atlas clusters indexes create

On this page

  • Syntax
  • Arguments
  • Options
  • Inherited Options
  • Examples

Create a rolling index for the specified cluster for your project.

To use this command, you must authenticate with a user account or an API key with the Project Data Access Admin role.

Command Syntax
atlas clusters indexes create [indexName] [options]
Name
Type
Required
Description
indexName
string
false
Name of the index.
Name
Type
Required
Description
--clusterName
string
true
Name of the cluster.
--collection
string
true
Name of the collection.
--db
string
true
Name of the database.
-h, --help
false
help for create
--key
strings
true
Field to be indexed and the type of index in the following format: field:type.
--projectId
string
false
Hexadecimal string that identifies the project to use. This option overrides the settings in the configuration file or environment variable.
--sparse
false
Flag that creates a sparse index. To learn more, see https://dochub.mongodb.org/core/index-sparse-manual.
Name
Type
Required
Description
-P, --profile
string
false
Name of the profile to use from your configuration file. To learn about profiles for the Atlas CLI, see https://dochub.mongodb.org/core/atlas-cli-save-connection-settings.
# Create an index named bedrooms_1 on the listings collection of the realestate database:
atlas clusters indexes create bedrooms_1 --clusterName Cluster0 --collection listings --db realestate --key bedrooms:1
# Create a compound index named property_room_bedrooms on the
listings collection of the realestate database:
atlas clusters indexes create property_room_bedrooms --clusterName Cluster0 --collection listings --db realestate --key property_type:1 --key room_type:1 --key bedrooms:1
←  atlas clusters indexesatlas clusters list →