elasticsearch basic concepts


This API is used for getting information about cluster and its nodes and making changes in them. For calling this API, we need to specify the node name, address or _local. For example,

GET http://localhost:9200/_nodes/_local

Response

………………………………………………
{
   "cluster_name":"elasticsearch", "nodes":{
      "Vy3KxqcHQdm4cIM22U1ewA":{
         "name":"Red Guardian", "transport_address":"127.0.0.1:9300", 
         "host":"127.0.0.1", "ip":"127.0.0.1", "version":"2.1.1", 
         "build":"40e2c53", "http_address":"127.0.0.1:9200",
      }
   }
}
………………………………………………

Or

Get http://localhost:9200/_nodes/127.0.0.1

Response

Same as in the above example.

Cluster Health

This API is used to get the status on the health of the cluster by appending health keyword. For example,

GET http://localhost:9200/_cluster/health

Response

{
   "cluster_name":"elasticsearch", "status":"yellow", "timed_out":false,
   "number_of_nodes":1, "number_of_data_nodes":1, "active_primary_shards":23,
   "active_shards":23, "relocating_shards":0, "initializing_shards":0,
   "unassigned_shards":23, "delayed_unassigned_shards":0, "number_of_pending_tasks":0,
   "number_of_in_flight_fetch":0, "task_max_waiting_in_queue_millis":0,
   "active_shards_percent_as_number":50.0
}

Cluster State

This API is used to get state information about a cluster by appending ‘state’ keyword URL. The state information contains version, master node, other nodes, routing table, metadata and blocks. For example,

GET http://localhost:9200/_cluster/state 10. Elasticsearch — Cluster APIs

Response

………………………………………………

{
   "cluster_name":"elasticsearch", "version":27, "state_uuid":"B3P7uHGKQUGsSsiX2rGYUQ",
   "master_node":"Vy3KxqcHQdm4cIM22U1ewA",
	
}
………………………………………………

Cluster Stats

This API helps to retrieve statistics about cluster by using ‘stats’ keyword. This API returns shard number, store size, memory usage, number of nodes, roles, OS, and file system. For example,

GET http://localhost:9200/_cluster/stats

Response

………………………………………………
{
   "timestamp":1454496710020, "cluster_name":"elasticsearch", "status":"yellow",
   "indices":{
      "count":5, "shards":{
         "total":23, "primaries":23, "replication":0.0,"
      }
   }
}		
………………………………………………

Pending Cluster Tasks

This API is used for monitoring pending tasks in any cluster. Tasks are like create index, update mapping, allocate shard, fail shard etc. For example,

GET http://localhost:9200/_cluster/pending_tasks

Cluster Reroute

This API is used for moving shard from one node to another or to cancel any allocation or allocate any unassigned shard. For example,

POST http://localhost:9200/_cluster/reroute

Request Body

{
   "commands" : [ 
      {
         "move" :
         {
            "index" : "schools", "shard" : 2,
            "from_node" : "nodea", "to_node" : "nodeb"
         }
      },
		
      {
         "allocate" : {
            "index" : "test", "shard" : 1, "node" : "nodec"
         }
      }
   ]
}

Cluster Update Settings

This API allows you to update the settings of a cluster by using settings keyword. There are two types of settings — persistent (applied across restarts) and transient (do not survive a full cluster restart).

Node Stats

This API is used to retrieve the statistics of one more nodes of the cluster. Node stats are almost the same as cluster. For example,

GET http://localhost:9200/_nodes/stats

Response

………………………………………………
{
   "cluster_name":"elasticsearch", "nodes":{
      "Vy3KxqcHQdm4cIM22U1ewA":{
         "timestamp":1454497097572, "name":"Red Guardian", 
         "transport_address":"127.0.0.1:9300", "host":"127.0.0.1", "ip":["127.0.0.1:9300",
      }
   }
}
………………………………………………

Nodes hot_threads

This API helps you to retrieve information about the current hot threads on each node in cluster. For example,

GET http://localhost:9200/_nodes/hot_threads

Response

………………………………………………
::: {Red Guardian} {Vy3KxqcHQdm4cIM22U1ewA} {127.0.0.1}{127.0.0.1:9300}Hot threads at 
   2016-02-03T10:59:48.856Z, interval = 500ms, busiestThreads = 3, 
   ignoreIdleThreads = true:0.0% (0s out of 500ms) cpu usage by thread 'Attach Listener'
      unique snapshot
      unique snapshot
………………………………………………

Table of Contents
1.elasticsearch tutorial

2.elasticsearch basic concepts

3.elasticsearch installation

4.elasticsearch populate

5.elasticsearch migration between versions

6.elasticsearch api conventions

7.elasticsearch document apis

8.elasticsearch search apis

9.elasticsearch aggregations

10.elasticsearch index apis

11.elasticsearch cluster apis

12.elasticsearch query dsl

13.elasticsearch mapping

14.elasticsearch analysis

15.elasticsearch modules

16.elasticsearch testing

17.elasticsearch quick guide

18.elasticsearch useful resources

19.discuss elasticsearch


Leave a Reply

Your email address will not be published. Required fields are marked *