How to do it...

For managing the index settings, we will perform the following steps:

  1. To retrieve the settings of your current index, use the following URL format: http://<server>/<index_name>/_settings
  2. We are reading information using the REST API, so the method will be GET. An example of a call, using the index we created in the Creating an index recipe, is as follows:
GET /myindex/_settings?pretty=true
  1. The response will be something similar to this:
{
"myindex" : {
"settings" : {
"index" : {
"routing" : {
"allocation" : {
"require" : {
"_name" : "1e9840cf42df"
}
}
},
"number_of_shards" : "1",
"blocks" : {
"write" : "true"
},
"provided_name" : "myindex",
"creation_date" : "1554578317870",
"number_of_replicas" : "1",
"uuid" : "sDzB7n80SFi8Of99IgLYtA",
"version" : {
"created" : "7000099"
}
}
}
}
}
  1. The response attributes depend on the index settings. In this case, the response will be the number of replicas (1), shards (2), and the index creation version (7000099). The UUID represents the unique ID of the index.
  1. To modify the index settings, we need to use the PUT method. A typical settings change is to increase the replica number:
PUT /myindex/_settings
{"index":{ "number_of_replicas": "2"}}