Make the MongoDB docs better! We value your opinion. Share your feedback for a chance to win $100.
Click here >
Docs Menu
Docs Home
/ /

atlas clústeres índices create

Crea un índice rotativo para el clúster especificado para tu proyecto.

Para usar este comando, debe autenticarse con una cuenta de usuario, una cuenta de servicio o una clave de API con el rol de Administrador de acceso a los datos del Proyecto.

Sintaxis del comando
atlas clusters indexes create [indexName] [options]
Nombre
Tipo
Requerido
Descripción

indexName

string

false

Nombre del índice.

Nombre
Tipo
Requerido
Descripción

--clusterName

string

true

Nombre del clúster. Para obtener más información, consulte https://dochub.mongodb.org/core/create-cluster-api.

--collection

string

false

Nombre de la colección.

Mutuamente excluyente con --archivo.

--db

string

false

Nombre de la base de datos.

Mutuamente excluyente con --archivo.

-f, --file

string

false

Ruta a un archivo de configuración JSON opcional que define los ajustes del índice. Nota: Se ignorarán todos los campos no soportados en el archivo JSON.

Mutuamente excluyente con --db, --collection, --key.

-h, --help

false

ayuda para crear

--key

Cuerdas

false

Campo a indexar y el tipo de índice en el siguiente formato: campo:tipo.

Mutuamente excluyente con --archivo.

--projectId

string

false

string hexadecimal que identifica el Proyecto a utilizar. Esta opción anula la configuración en el archivo de configuración o la variable de entorno.

--sparse

false

Bandera que crea un índice disperso. Para aprender más, consulta https://dochub.mongodb.org/core/index-sparse-manual.

Nombre
Tipo
Requerido
Descripción

-P, --profile

string

false

Nombre del perfil a usar de tu archivo de configuración. Para aprender sobre los perfiles para Atlas CLI, consulta 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
# Create an index named my_index from a JSON configuration file named myfile.json:
atlas clusters indexes create my_index --clusterName Cluster0 --file file.json

Volver

indexes

En esta página