liveBook · Manning

Action.auto_create_index

As explained in Elasticsearch in Action, Second Edition

action.auto_create_index is an Elasticsearch setting that controls whether missing indexes may be created automatically.

`action.auto_create_index` controls whether Elasticsearch may create a missing index when a request writes to it. It is enabled by default. Set it to `false` when indexes should be created deliberately with predefined mappings, shard choices, aliases, or other settings instead of appearing on demand. section 5.1.1 section 6.2

Block implicit index creation

Disable automatic creation cluster-wide with a persistent setting: PUT _cluster/settings { "persistent": { "action.auto_create_index": false } } Afterward, a request such as `PUT my_new_index/_doc/1` fails if `my_new_index` does not already exist. Create the index first, then index documents into it. section 5.1.1 section 6.2.1

Use `persistent` when the choice should survive an Elasticsearch restart. A `transient` cluster setting lasts only until the next server reboot. 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 request applies the binary cluster-wide setting. It is useful when every index must be provisioned before documents arrive. section 6.2.1

Turning the feature off completely can be too restrictive: applications and Kibana may need to create administrative indexes, including hidden indexes whose names begin with a dot. Prefer selective rules when only some index names need automatic creation. section 6.2.1

action.auto_create_index: [".admin*, cars*, "*books*", "-x*","-y*","+z*"]

A comma-separated rule list can allow automatic creation for matching names and disallow it for names prefixed with `-`; `+` marks allowed patterns. section 6.2.1

This setting protects index design rather than document overwrites. Use the `_create` endpoint when a document must not replace an existing document; use explicit index-creation APIs when mappings, shards, replicas, compression, or aliases need to be chosen up front. section 5.1.1 section 6.2

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains binary and selective cluster-wide rules, persistent versus transient scope, and operational caveats without detailing pattern syntax further.
Examples
Uses writes to movies and cars indexes, a disabled-setting request, and allow/disallow name patterns.
What it assumes
Introduces the setting through document indexing and index creation requests without requiring prior configuration knowledge.
What you can do after
Operate/configure it through elasticsearch.yml or the cluster settings API to require explicit or selective index creation.
How it connects
Connects automatic creation to cluster settings, index mappings, shards, replicas, aliases, Kibana, and the _create endpoint.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.