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 and Authentication

curl -X GET 'https://opensearch-host:9200' -u 'username:password'
Test connection to OpenSearch server

curl -X GET 'https://opensearch-host:9200/_cluster/health' -u 'username:password'
Check cluster health

curl -X GET 'https://opensearch-host:9200/_cat/indices' -u 'username:password'
List all indices

Index Management

curl -X PUT 'https://opensearch-host:9200/index-name' -u 'username:password' -H 'Content-Type: application/json' -d '{"settings":{"index":{"number_of_shards":3,"number_of_replicas":2}}}'
Create an index with settings

curl -X DELETE 'https://opensearch-host:9200/index-name' -u 'username:password'
Delete an index

curl -X GET 'https://opensearch-host:9200/index-name/_settings' -u 'username:password'
Get index settings

curl -X PUT 'https://opensearch-host:9200/index-name/_mapping' -u 'username:password' -H 'Content-Type: application/json' -d '{"properties":{"field1":{"type":"text"}}}'
Update index mapping

Document Operations

curl -X POST 'https://opensearch-host:9200/index-name/_doc' -u 'username:password' -H 'Content-Type: application/json' -d '{"field1":"value1"}'
Index a document with auto-generated ID

curl -X PUT 'https://opensearch-host:9200/index-name/_doc/id1' -u 'username:password' -H 'Content-Type: application/json' -d '{"field1":"value1"}'
Index a document with specified ID

curl -X GET 'https://opensearch-host:9200/index-name/_doc/id1' -u 'username:password'
Get a document by ID

curl -X DELETE 'https://opensearch-host:9200/index-name/_doc/id1' -u 'username:password'
Delete a document by ID

curl -X POST 'https://opensearch-host:9200/index-name/_update/id1' -u 'username:password' -H 'Content-Type: application/json' -d '{"doc":{"field1":"new_value"}}'
Update a document

Search and Query

curl -X GET 'https://opensearch-host:9200/index-name/_search' -u 'username:password' -H 'Content-Type: application/json' -d '{"query":{"match_all":{}}}'
Search all documents in an index

curl -X GET 'https://opensearch-host:9200/index-name/_search' -u 'username:password' -H 'Content-Type: application/json' -d '{"query":{"match":{"field1":"value1"}}}'
Search documents matching a field value

curl -X GET 'https://opensearch-host:9200/index-name/_search' -u 'username:password' -H 'Content-Type: application/json' -d '{"query":{"bool":{"must":[{"match":{"field1":"value1"}}],"filter":[{"range":{"age":{"gte":30}}}]}}}'
Complex boolean query

curl -X GET 'https://opensearch-host:9200/index-name/_search' -u 'username:password' -H 'Content-Type: application/json' -d '{"query":{"match_all":{}},"sort":[{"timestamp":"desc"}],"size":20,"from":0}'
Paginated search with sorting

Aggregations

curl -X GET 'https://opensearch-host:9200/index-name/_search' -u 'username:password' -H 'Content-Type: application/json' -d '{"size":0,"aggs":{"avg_value":{"avg":{"field":"numeric_field"}}}}'
Calculate average of a field

curl -X GET 'https://opensearch-host:9200/index-name/_search' -u 'username:password' -H 'Content-Type: application/json' -d '{"size":0,"aggs":{"categories":{"terms":{"field":"category"}}}}'
Group by and count values in a field

curl -X GET 'https://opensearch-host:9200/index-name/_search' -u 'username:password' -H 'Content-Type: application/json' -d '{"size":0,"aggs":{"date_histogram":{"date_histogram":{"field":"timestamp","calendar_interval":"day"}}}}'
Time-based aggregation

Cluster Management

curl -X GET 'https://opensearch-host:9200/_cluster/health' -u 'username:password'
Check cluster health status

curl -X GET 'https://opensearch-host:9200/_cat/nodes?v' -u 'username:password'
List all nodes in the cluster

curl -X GET 'https://opensearch-host:9200/_cluster/stats' -u 'username:password'
Get cluster statistics

curl -X GET 'https://opensearch-host:9200/_cat/shards?v' -u 'username:password'
View shard allocation across nodes

Templates and Aliases

curl -X PUT 'https://opensearch-host:9200/_index_template/template_name' -u 'username:password' -H 'Content-Type: application/json' -d '{"index_patterns":["pattern*"],"template":{"settings":{"number_of_shards":1}}}'
Create an index template

curl -X POST 'https://opensearch-host:9200/_aliases' -u 'username:password' -H 'Content-Type: application/json' -d '{"actions":[{"add":{"index":"index-name","alias":"alias-name"}}]}'
Create an alias for an index

Monitoring and Diagnostics

curl -X GET 'https://opensearch-host:9200/_cat/indices?v' -u 'username:password'
List all indices with stats

curl -X GET 'https://opensearch-host:9200/_cat/allocation?v' -u 'username:password'
View disk allocation

curl -X GET 'https://opensearch-host:9200/_nodes/stats' -u 'username:password'
Get detailed node statistics

curl -X GET 'https://opensearch-host:9200/_tasks' -u 'username:password'
List running tasks