Elasticsearch cheat sheet


Check installed plugins on a node:

curl -XGET 'http://localhost:9200/_nodes/NODE_NAME/plugins?pretty=yes'


Check shards recovery:

curl -XGET http://localhost:9200/_cat/recovery

Check shards status:

curl -XGET http://localhost:9200/_cat/shards

Deactivate/Activate dynamic rellocation:

curl -XPUT localhost:9200/_cluster/settings -d '{ "transient" : { "cluster.routing.allocation.enable" : "none" } }'
curl -XPUT 'localhost:9200/_cluster/settings' -d '{ "transient" : { "cluster.routing.allocation.enable" : "all" } }'

Relocating shard:

curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
        "commands" : [ {
              "allocate" : {
                  "index" : "INDEX_NAME", 
                  "shard" : SHARD_NUMBER, 
                  "node" : "NODE", 
                  "allow_primary" : true


Check cluster health:

curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'

Check pending tasks:

curl -XGET 'http://localhost:9200/_cluster/pending_tasks&pretty=true'

List nodes:

curl -XGET 'http://localhost:9200/_cat/nodes?v'


Set replica count:

curl -XPUT 'localhost:9200/my_index/_settings' -d ' 
  "index" : { "number_of_replicas" : 4 } 


List indexes:

curl 'localhost:9200/_cat/indices?v'

Delete index:

curl -XDELETE 'http://localhost:9200/twitter/'


Debugging startup problems:

Add a line into /etc/init.d/elasticsearch to print out the the start command:

# Start Daemon
log_daemon_msg "sudo -u $ES_USER $DAEMON $DAEMON_OPTS"    # <-- Add this line
start-stop-daemon --start -b --user "$ES_USER" -c "$ES_USER" --pidfile "$PID_FILE" --exec $DAEMON -- $DAEMON_OPTS
log_end_msg $?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s