How to define default Elasticsearch index settings

Use templates to define default Elasticsearch index settings.

Define default_index template that will be used for every newly created index. It has lowest possible order, so can be easily overridden by the ones with higher order value. Version value is just an integer, for your information only.

$ curl -XPUT  -H 'Content-Type: application/json' 'http://10.0.2.15:9200/_template/default_index?pretty=true' -d '{
    "index_patterns": ["*"],
    "order": "0", 
    "version": 1,
    "settings": {"index": { "number_of_shards": "1", "number_of_replicas": "0"} }
}'
{
  "acknowledged" : true
}

List templates.

$ curl -XGET 'http://10.0.2.15:9200/_cat/templates/?v'
name          index_patterns order version
default_index [*]            0     1

Display specific template.

$ curl -XGET 'http://10.0.2.15:9200/_template/default_index?pretty=true'
{
  "default_index" : {
    "order" : 0,
    "version" : 1,
    "index_patterns" : [
      "*"
    ],
    "settings" : {
      "index" : {
        "number_of_shards" : "1",
        "number_of_replicas" : "0"
      }
    },
    "mappings" : { },
    "aliases" : { }
  }
}

Delete specific template.

$ curl -XDELETE 'http://10.0.2.15:9200/_template/default_index?pretty=true'
{
  "acknowledged" : true
}