Book Image

ElasticSearch Cookbook

By : Alberto Paro
Book Image

ElasticSearch Cookbook

By: Alberto Paro

Overview of this book

Table of Contents (20 chapters)
ElasticSearch Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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]",
            "attributes" : { }
          },
          "68PBx8g5TZKRxTMii9_EFw" : {
            "name" : "Azazel",
            "transport_address" : "inet[/192.168.1.13:9301]",
            "attributes" : { }
          }
        },
    • Cluster metadata...