Dennis Zheleznyak

Dennis Zheleznyak

DevOps Engineer bigpanda

© 2021

Set number of replicas for index/indices

To change the number of replicas for a an index, you can use the following one liner command:

curl -s -X PUT "localhost:9200/<IndexName>/_settings" -H 'Content-Type: application/json' -d' { "index" : { "number_of_replicas" : 1 } }'

You can also use a for loop to go over a list:

curl -s localhost:9200/_cat/indices?pretty | cut -d" " -f4 > all_indices

vi all_indices      <==== If you need to pull some indices out

for i in $(cat all_indices); do curl -s -X PUT "localhost:9200/$i/_settings" -H 'Content-Type: application/json' -d' { "index" : { "number_of_replicas" : 1 } }'; done