elasticsearch commands

19 commands, each with a one-line explanation. Click a command to copy it, or its title for details.

Commands 19 shown

  • curl -s http://localhost:9200/_cluster/health | jq .

    Show cluster status: green/yellow/red, shards, nodes

    monitoring

  • curl -s 'http://localhost:9200/_cat/indices?v&h=index,health,pri,rep,docs.count,store.size&s=store.size:desc'

    Tabular index listing sorted by size

  • curl -X DELETE http://localhost:9200/<index>

    Remove an index and all its data

  • curl -s http://localhost:9200/<index>/_settings | jq .

    Inspect number of shards, replicas, refresh interval

  • curl -X POST http://localhost:9200/_reindex -H 'Content-Type: application/json' -d '{"source":{"index":"old"},"dest":{"index":"new"}}'

    Copy documents from one index to another

  • curl -X POST 'http://localhost:9200/<index>/_forcemerge?max_num_segments=1'

    Reduce segment count; useful before making index read-only

  • curl -s http://localhost:9200/_cat/nodes?v

    Show all ES nodes with JVM heap, load, roles

    monitoring

  • curl -s -X POST http://localhost:9200/<index>/_search -H 'Content-Type: application/json' -d '{"query":{"match":{"message":"error"}}}'

    Full-text search for documents matching a term

  • curl -X PUT http://localhost:9200/_snapshot/<repo>/<snapshot>

    Create a snapshot to the registered repository

  • curl -s 'http://localhost:9200/<index>/_ilm/explain' | jq '.indices | to_entries[] | {index:.key, phase:.value.phase, action:.value.action}'

    Show current ILM lifecycle phase and action for an index

  • curl -s http://es:9200/_cluster/health?pretty

    Show cluster status: green/yellow/red with shard counts

    monitoring

  • curl -s 'http://es:9200/_cat/indices?v&s=store.size:desc'

    All indices sorted by store size (largest first)

    monitoring

  • curl -X DELETE http://es:9200/logs-2024.01.01

    Remove a specific index (irreversible)

  • curl -X GET 'http://es:9200/logs-*/_search?pretty' -H 'Content-Type: application/json' -d '{"query":{"match":{"level":"error"}},"size":5}'

    Find last 5 error log entries

    debug

  • curl -s 'http://es:9200/_cat/shards?v&h=index,shard,prirep,state,node,unassigned.reason'

    Show all shards with their state and unassigned reason

    debug

  • curl -X POST http://es:9200/_cluster/reroute?retry_failed=true

    Retry allocation of all failed/unassigned shards

    debug

  • curl -X PUT 'http://es:9200/my-index/_settings' -H 'Content-Type: application/json' -d '{"index":{"number_of_replicas":1}}'

    Change replica count on a live index

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

    Auto-configure new indices matching logs-*

  • curl -X PUT 'http://es:9200/_snapshot/my_repo/snap1?wait_for_completion=true'

    Create a cluster snapshot synchronously