Controlling cluster state via the API
The previous recipe returns information only about the health of the cluster. If you need more details about your cluster, you need to query its state.
Getting ready
You need a working ElasticSearch cluster.
How to do it...
To check the cluster state, we will perform the steps given as follows:
- 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 contain the following data sections:
- General cluster information:
{ "cluster_name" : "es-cookbook", "version" : 13, "master_node" : "R3Gwu0a6Q9GTHPQ6cg95ZA", "blocks" : { }, Node address information: "nodes" : { "R3Gwu0a6Q9GTHPQ6cg95ZA" : { "name" : "Man-Ape", "transport_address" : "inet[/192.168.1.13:9300]", "attributes" : { } }, "68PBx8g5TZKRxTMii9_EFw...
- General cluster information: