Automatic index creation lets Elasticsearch create a missing index when the first document is indexed into it. A request such as PUT cars/_doc/1 can therefore begin storing data without a separate index-creation call. The new index receives default settings, including a primary shard and replica, and Elasticsearch uses dynamic mapping to infer field types from the incoming document. section 6.2 section 6.2.1
Listing 6.1 First document containing car data
DELETE cars #1
PUT cars/_doc/1 #2
{
"make":"Maserati",
"model":"GranTurismo Sport",
"speed_mph":186
}
Indexing the first car document after deleting cars triggers creation of the missing cars index. section 6.2.1
This convenience is useful for quick ingestion, but it trades control for speed. In production, an inferred mapping can be wrong: a non-ISO date such as dd-MM-yyyy or MM-dd-yyyy may be classified as text rather than a date. Automatically applied settings can also be unsuitable, and some static settings, including the primary-shard count, cannot be changed while an index is operational. section 6.2 section 6.2.1
Choose the creation approach to fit the workload:
- Use implicit creation when default settings and dynamically inferred mappings are acceptable for the data being indexed. section 6.10 section 6.2
- Create an index explicitly before ingestion when it needs custom mappings, shard allocation, aliases, or other tailored settings. section 6.10 section 6.2
- Use an index template when matching index names should receive predetermined configuration during creation. section 6.10
Control automatic creation
Automatic creation is enabled by default. Set action.auto_create_index to false through the cluster settings API or elasticsearch.yml to make indexing into an absent index fail instead. A persistent cluster setting survives server reboots; a transient setting lasts only until the next reboot. Fully disabling creation can interfere with administrative indexes needed by an application or Kibana, so selective comma-separated allow and disallow patterns offer a narrower alternative. section 5.1.1 section 6.2.1
Listing 6.2 Disabling automatic creation of indexes
PUT _cluster/settings #1
{
"persistent": { #2
"action.auto_create_index":false #3
}
}
This cluster-settings request persistently disables automatic creation for indexes. section 6.2.1
