Setting index.number_of_replicas => 0 by default in ES >= 5

To prevent new indices from having replica shards you will need to create an Index template in your 1-node cluster, which is automatically applied during index creation.

For instance, if you want to set the number of replicas to 0 for new logstash indices you will have to add something like this:

curl -XPUT "localhost:9200/_template/logstash_template" -H 'Content-Type: application/json' -d'
{
  "index_patterns": ["logstash*"],
  "settings": {
    "number_of_replicas": 0
  }
}
'

The crucial element here is "index_patterns" which must match the start of the index names. If you want this setting to work for all indices (though I haven't tried this myself), you should be able to do:

curl -XPUT "localhost:9200/_template/default_template" -H 'Content-Type: application/json' -d'
{
  "index_patterns": ["*"],
  "settings": {
    "number_of_replicas": 0
  }
}
'

Here the asterisk should match all new index names.

1 Like