Number of Replicas is always 1 by default

All our indices were "yellow" and we discovered it's because the number of replicas was set to 1. When we update the number of replicas to 0 the indexes are green.

Because we periodically re-create our indices and re-index them we added the following to our index creation:

{
    "index" : {
        "number_of_replicas" : 0
    },
    "mappings": {
        "doc": {
            "properties": {
                ...

However, such indices are still created with number_of_replicas = 1 as is visible in: GET /_cat/indices:

health status index            uuid pri rep docs.count
yellow open   logs-test1       ...   5   1    3316531 
  1. Why does ES set 1 by default? Sounds wrong.
  2. Why does ES ignore the 0 when we create the index?

It is because the default is always one
as you are only having one instance thats why the status is yellow

Why is the default 1? => Because it is 1. OK, that's cleared that up for us.

Please show exactly how you create the index.

PUT /logs-test1

{
    "index" : {
        "number_of_replicas" : 0
    },
    "mappings": {
        "doc": {
            "properties": {
                "category": {"type": "keyword"},
                "id": {"type": "long"},
                "subcategory": {"type": "keyword"},
                "timestamp": {"type": "date","format": "date_time||epoch_millis"},
                "type": {"type": "keyword"}
            }
        }
    }
}

You are missing the settings level, which is why your settings are not recognised:

PUT /logs-test1
{
  "settings": {
    "index" : {
      "number_of_replicas" : 0
    }
  },
  "mappings": {
    "doc": {
      "properties": {
        "category": {"type": "keyword"},
        "id": {"type": "long"},
        "subcategory": {"type": "keyword"},
        "timestamp": {"type": "date","format": "date_time||epoch_millis"},
        "type": {"type": "keyword"}
      }
    }
  }
}

Thanks muchly!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.