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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.