$ command-helper

Elasticsearch / OpenSearch

Cluster health, indices and shards, searching, mappings and reindexing — via the REST API with curl.

Requires Google sign-in

Cluster

Cluster health
curl -s '<es>/_cluster/health?pretty'
Nodes with load and disk
curl -s '<es>/_cat/nodes?v&h=name,cpu,load_1m,heap.percent,disk.used_percent,node.role'
Disk allocation per node
curl -s '<es>/_cat/allocation?v'
Why a shard is unassignedadvanced
curl -s '<es>/_cluster/allocation/explain?pretty'

Indices

List indices sorted by size
curl -s '<es>/_cat/indices?v&s=store.size:desc'
Shards of an index
curl -s '<es>/_cat/shards/<index>?v'
Index mapping
curl -s '<es>/<index>/_mapping?pretty'
Delete an index
curl -X DELETE '<es>/<index>'
Aliases
curl -s '<es>/_cat/aliases?v'

Search

Quick search with query string
curl -s '<es>/<index>/_search?q=status:error&size=5&pretty'
Count documents
curl -s '<es>/<index>/_count?pretty'
Search with a JSON query
curl -s '<es>/<index>/_search?pretty' -H 'Content-Type: application/json' -d '
{
  "query": { "match": { "message": "timeout" } },
  "size": 10,
  "sort": [{ "@timestamp": "desc" }]
}'
Get a document by id
curl -s '<es>/<index>/_doc/<id>?pretty'

Maintenance

Copy data into a new indexadvanced
curl -X POST '<es>/_reindex?wait_for_completion=false' -H 'Content-Type: application/json' -d '
{ "source": { "index": "<index>" }, "dest": { "index": "<index>-v2" } }'
Running tasks (e.g. reindex progress)advanced
curl -s '<es>/_tasks?actions=*reindex&detailed&pretty'
Unblock indices after the disk filled upadvanced
curl -X PUT '<es>/_all/_settings' -H 'Content-Type: application/json' \
  -d '{ "index.blocks.read_only_allow_delete": null }'