Controlling cluster state via API
The previous recipe returns information only about the health of the cluster. If you need more details on your cluster, you need to query its state.
Getting ready
You need a working ElasticSearch cluster.
How to do it…
For controlling the cluster state, we need to perform the following steps:
- To view the cluster state, the HTTP method is GET and the curl command is:
curl -XGET 'http://localhost:9200/_cluster/state'
- The result will be:
{ "cluster_name" : "elasticsearch", "master_node" : "pyGyXwh1ScqmnDw5etNS0w", "blocks" : { }, "nodes" : { "pyGyXwh1ScqmnDw5etNS0w" : { "name" : "Wonder Man", "transport_address" : "inet[/192.168.1.5:9300]", "attributes" : { } }, "wOIonUlFTwec0DCgf3aOjA" : { "name" : "Enigma", "transport_address" : "inet...