Category Archives: cheat sheet

Elasticsearch cheat sheet

PLUGINS

Check installed plugins on a node:

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

SHARDS

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
              }
            }
        ]
    }'

CLUSTER

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'

INDEX

Set replica count:

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

Reference

List indexes:

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

Delete index:

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

MISC

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 $?
Advertisements