Curl command to set the number of replicas

Hi All ,

Please help me with the CURL command to change the "number_of_replicas" on Elasticsearch 5.0, the below command is not currently working with same-
curl -XPUT http://localhost:9200/_settings -d {"number_of_replicas":0}

Please suggest if anything missing .

Regards,
Prateek Divya

You need to do that per index: https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-update-settings.html

curl -XPUT 'localhost:9200/my_index/_settings' -d '{
    "index.number_of_replicas" : 0
}'

It is also possible to create a top-level template that would apply to all newly-created indices.

I tried the same but getting error as "Could not resolve host : 0"

ELK is on windows machine so if that could impact anywhere.

Please suggest how to create a top-level template. I have not done earlier so have no context around same.

You can do it like this:

PUT localhost:9200/_template/number_of_replicas
{
  "template": "*",
  "settings": {
    "number_of_replicas": 0
  }
}

See the docs for more details.

1 Like

Thanks David. It worked when tried the same on Kibana console not on explicit CURl command line

Thanks Jason. It helped with the same.

You're very welcome.

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