Commands Cheat Sheet

Evaluating engineering tools? Get the comparison in Google Sheets

(Perfect for making buy/build decisions or internal reviews.)

Most-used commands
Your email is safe thing.

Thankyou for your submission

We have sent the cheatsheet on your email!
Oops! Something went wrong while submitting the form.

Connection

curl -X GET 'http://localhost:9200'
Check if Elasticsearch is running and get basic info

curl -X GET 'http://localhost:9200/_cat/health?v'
Check cluster health

curl -u username:password -X GET 'http://localhost:9200'
Connect with basic authentication

Indices

curl -X GET 'http://localhost:9200/_cat/indices?v'
List all indices

curl -X PUT 'http://localhost:9200/my_index'
Create an index

curl -X DELETE 'http://localhost:9200/my_index'
Delete an index

curl -X GET 'http://localhost:9200/my_index/_settings'
View index settings

curl -X GET 'http://localhost:9200/my_index/_mapping'
View index mapping

Documents

curl -X POST 'http://localhost:9200/my_index/_doc' -H 'Content-Type: application/json' -d '{"field": "value"}'
Index a document with auto-generated ID

curl -X PUT 'http://localhost:9200/my_index/_doc/1' -H 'Content-Type: application/json' -d '{"field": "value"}'
Index a document with specified ID

curl -X GET 'http://localhost:9200/my_index/_doc/1'
Get a document by ID

curl -X DELETE 'http://localhost:9200/my_index/_doc/1'
Delete a document

curl -X POST 'http://localhost:9200/my_index/_update/1' -H 'Content-Type: application/json' -d '{"doc": {"field": "new_value"}}'
Update a document

Search

curl -X GET 'http://localhost:9200/my_index/_search'
Simple search (match all)

curl -X GET 'http://localhost:9200/my_index/_search' -H 'Content-Type: application/json' -d '{"query": {"match": {"field": "value"}}}'
Query by field match

curl -X GET 'http://localhost:9200/my_index/_search' -H 'Content-Type: application/json' -d '{"query": {"bool": {"must": [{"match": {"field": "value"}}]}}}'
Boolean query

curl -X GET 'http://localhost:9200/my_index/_search' -H 'Content-Type: application/json' -d '{"query": {"range": {"numeric_field": {"gte": 10, "lte": 20}}}}'
Range query

curl -X GET 'http://localhost:9200/my_index/_search' -H 'Content-Type: application/json' -d '{"query": {"query_string": {"query": "field:value"}}}'
Query string query

Aggregations

curl -X GET 'http://localhost:9200/my_index/_search' -H 'Content-Type: application/json' -d '{"size": 0, "aggs": {"avg_value": {"avg": {"field": "numeric_field"}}}}'
Calculate average of a field

curl -X GET 'http://localhost:9200/my_index/_search' -H 'Content-Type: application/json' -d '{"size": 0, "aggs": {"categories": {"terms": {"field": "category.keyword"}}}}'
Group by a field and count

curl -X GET 'http://localhost:9200/my_index/_search' -H 'Content-Type: application/json' -d '{"size": 0, "aggs": {"date_histogram": {"date_histogram": {"field": "date", "calendar_interval": "month"}}}}'
Date histogram aggregation

Cluster Management

curl -X GET 'http://localhost:9200/_cluster/health'
Get detailed cluster health

curl -X GET 'http://localhost:9200/_cluster/stats'
Get cluster stats

curl -X GET 'http://localhost:9200/_nodes/stats'
Get nodes stats

curl -X GET 'http://localhost:9200/_cat/shards?v'
View shards allocation

curl -X PUT 'http://localhost:9200/_cluster/settings' -H 'Content-Type: application/json' -d '{"persistent": {"cluster.routing.allocation.enable": "all"}}'
Update cluster settings

Snapshots

curl -X PUT 'http://localhost:9200/_snapshot/my_backup' -H 'Content-Type: application/json' -d '{"type": "fs", "settings": {"location": "/path/to/backup"}}'
Register a snapshot repository

curl -X PUT 'http://localhost:9200/_snapshot/my_backup/snapshot_1'
Create a snapshot

curl -X GET 'http://localhost:9200/_snapshot/my_backup/snapshot_1'
Get snapshot info

curl -X POST 'http://localhost:9200/_snapshot/my_backup/snapshot_1/_restore'
Restore a snapshot