elasticsearch
19 commands
19 shown
Cluster health
Show cluster status: green/yellow/red, shards, nodes
curl -s http://localhost:9200/_cluster/health | jq .
List indices
Tabular index listing sorted by size
curl -s 'http://localhost:9200/_cat/indices?v&h=index,health,pri,rep,docs.count,store.size&s=store.size:desc'
Delete index
Remove an index and all its data
curl -X DELETE http://localhost:9200/<index>
Get index settings
Inspect number of shards, replicas, refresh interval
curl -s http://localhost:9200/<index>/_settings | jq .
Reindex
Copy documents from one index to another
curl -X POST http://localhost:9200/_reindex -H 'Content-Type: application/json' -d '{"source":{"index":"old"},"dest":{"index":"new"}}'
Force merge index
Reduce segment count; useful before making index read-only
curl -X POST 'http://localhost:9200/<index>/_forcemerge?max_num_segments=1'
Node stats
Show all ES nodes with JVM heap, load, roles
curl -s http://localhost:9200/_cat/nodes?v
Search query
Full-text search for documents matching a term
curl -s -X POST http://localhost:9200/<index>/_search -H 'Content-Type: application/json' -d '{"query":{"match":{"message":"error"}}}'
Snapshot create
Create a snapshot to the registered repository
curl -X PUT http://localhost:9200/_snapshot/<repo>/<snapshot>
ILM explain index
Show current ILM lifecycle phase and action for an index
curl -s 'http://localhost:9200/<index>/_ilm/explain' | jq '.indices | to_entries[] | {index:.key, phase:.value.phase, action:.value.action}'
Check cluster health
Show cluster status: green/yellow/red with shard counts
curl -s http://es:9200/_cluster/health?pretty
List indices with size
All indices sorted by store size (largest first)
curl -s 'http://es:9200/_cat/indices?v&s=store.size:desc'
Delete old index
Remove a specific index (irreversible)
curl -X DELETE http://es:9200/logs-2024.01.01
Search with query DSL
Find last 5 error log entries
curl -X GET 'http://es:9200/logs-*/_search?pretty' -H 'Content-Type: application/json' -d '{"query":{"match":{"level":"error"}},"size":5}'
Show shards allocation
Show all shards with their state and unassigned reason
curl -s 'http://es:9200/_cat/shards?v&h=index,shard,prirep,state,node,unassigned.reason'
Force shard re-allocation
Retry allocation of all failed/unassigned shards
curl -X POST http://es:9200/_cluster/reroute?retry_failed=true
Update index settings
Change replica count on a live index
curl -X PUT 'http://es:9200/my-index/_settings' -H 'Content-Type: application/json' -d '{"index":{"number_of_replicas":1}}'
Create index template
Auto-configure new indices matching logs-*
curl -X PUT 'http://es:9200/_index_template/logs-tpl' -H 'Content-Type: application/json' -d '{"index_patterns":["logs-*"],"template":{"settings":{"number_of_shards":2}}}'
Snapshot to repository
Create a cluster snapshot synchronously
curl -X PUT 'http://es:9200/_snapshot/my_repo/snap1?wait_for_completion=true'
no commands match