Atlas Search Index Configuration File
On this page
You can use an Atlas Search index configuration file to specify the required
settings for creating a search index using the Atlas CLI. The
Atlas CLI accepts .json
search index configuration files. You
can use the .json
search index configuration file to create the
index for cloud and
local Atlas
deployments.
Atlas Search Index Settings
You can specify the following settings in the Atlas Search index configuration file. For a full list of available settings, see the request body schema in the API specification: Create One Atlas Search Index.
Field | Type | Description |
---|---|---|
| string | Label that identifies the collection for which you want to create an Atlas Search index. |
| string | Label that identifies the database that contains the collection for which you want to create an Atlas Search index. |
| string | Label that identifies this index. Within each namespace, names of all indexes in the namespace must be unique. |
| object | Index specifications for the collection's fields. |
| boolean | Flag that indicates whether the index uses dynamic or static
mappings. If omitted or if set to |
Example Atlas Search Index Configuration File
To create an Atlas Search index, define the search index in your JSON file as shown in the following example file:
The following configuration automatically indexes all dynamically
indexable fields in the sample_airbnb.listingsAndReviews
collection.
{ "collectionName": "listingsAndReviews", "database": "sample_airbnb", "name": "myIndex", "mappings": { "dynamic": true } }
The following configuration indexes only the name
and
property_type
fields in the
sample_airbnb.listingsAndReviews
collection.
{ "collectionName": "listingsAndReviews", "database": "sample_airbnb", "name": "myIndex", "mappings": { "dynamic": false, "fields": { "name": { "type": "string" }, "property_type": { "type": "string" } } } }
Example Atlas Search Index Create Command
After you create the file, run the command to create the Atlas Search
search index and specify the clusterName
and the file
. The
following example creates a search index for the cluster named
myCluster
using a JSON index configuration file named
search-config.json
:
atlas clusters search indexes create --clusterName myCluster --file search-config.json --output json
After you create the file, run the command to create the Atlas Search
search index and specify the deploymentName
and the file
.
The following example creates a search index for a deployment
named myLocalRs
using a JSON index configuration file named
search-config.json
:
atlas deployments search indexes create --deploymentName myLocalRs --file search-config.json --output json