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:

  1. To view the cluster state, the HTTP method is GET and the curl command is:
    curl -XGET 'http://localhost:9200/_cluster/state'
  2. 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]", ...

Get ElasticSearch Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.