OpenSearch Important API Commands
Handy API commands for working with OpenSearch clusters.
API: Application Programming Interfaces.
The API commands help users to interact with OpenSearch clusters. This interaction helps to perform different tasks quickly and easily.
To execute all the API commands mentioned below, can be copied and pasted in OpenSearch_dashboard > stack management > Dev tools.
Note: The following API commands provide the status in OpenSearch.
| Action | Commands |
|---|---|
| Get Indices for a date sorted on storage size | |
| Get Indices for a date sorted on the document count | |
| Get Node-wise Index allocation stats sorted on available disk on the node | |
| Simple basic get indices with headers | |
| Get indices sorted on storage size | |
| Get all Indices sorted on doc count | |
| Get Shards sorted on store size | |
| Get Shards sorted on max docs | |
| Get Shards with a custom field list | |
| Get un-assigned shards and Reason | |
| Explain the reason for unassigned shards | |
| Retry allocation for unassigned shards/ | |
| List all Nodes in cluster | |
| Get stats | |
| Get Node-wise Thread Pool Count/Size | |
| Get Thread Pool Stats based on rejections | |
| GET Detailed Thread Pool Stats based on rejections | |
| Get Indexing Stats | |
| Get Nodes in Cluster | |
| GET Nodes in Cluster with Custom Field Order | |
| Get Node attributes | |
| Get Shards sorted on Index | |
| GET Cluster Health | |
| GET cluster state | |
| GET Cluster Node Hot Threads | |
| GET Cluster Stats | |
| GET RECOVERY Status | |
| GET Pending Tasks | |
| GET List of running tasks | |
| Cancel all tasks with the action as search | |
| Get details of all search tasks | |
| Cancel a task based on the task ID | |
| GET Cluster health for Index level | |
| GET Cluster health for the shard level | |
| The command below is equivalent to tail -f on Unix | |
| The command below is equivalent to More on Unix | |
| The command below is equivalent to tail on Unix | |
| Execute the below to change the disk-based shard allocation setting | |
| Move a particular Shard from one node to another | |
| Enable Cluster Routing allocation for all nodes | |
| Increase the node_left delay timeout for an index | |
| Manually allocate stale primary shards or allocate_empty_primary | |
Note: The following API commands help in sending queries.
All the below API commands can be executed as curl commands:
1. All GET/DELETE APIs can be executed as shown:
curl -u <UserName>:<Password> -XGET "http://<OpenSearchHost>:<OpenSearchPort>/<APICommand>"
curl -u <UserName>:<Password> -XDELETE "http://<OpenSearchHost>:<OpenSearchPort>/<APICommand>"
2. All PUT/POST APIs can be executed as shown:
curl -u <UserName>:<Password> -XPUT "http://<OpenSearchHost>:<OpenSearchPort>/<APICommand>" -H 'Content-Type: application/json' -d'{<JSON REQUEST BODY>}'
curl -u <UserName>:<Password> -XPOST "http://<OpenSearchHost>:<OpenSearchPort>/<APICommand>" -H 'Content-Type: application/json' -d'{<JSON REQUEST BODY>}'
| Action | Command |
|---|---|
| Create Index | |
| Delete Index | |
| Search Index | |
- Index Mapping
Index mapping refers to the configuration of the data structure and properties of an index.
It determines the following:
- Data storage
- Indexing data
- How to perform a search of the data
- How to perform a query on the data
| Action | Command |
|---|---|
| Create new ISM policy | |
| Get specific ISM policy | |
| List all ISM policies | |
| Delete ISM policy | |
| Create ingest-pipeline | |
| Get a specific ingest pipeline | |
| List all ingest pipelines | |
| Delete ingest-pipeline | |
| Simulate ingest-pipeline | |
| Monitor the Ingest pipeline performance | |
| Create rollup-job | |
| Get a specific rollup job | |
| List all rollup-jobs | |
| Delete rollup-job | |
| Create index template | |
| Get index template | |
| Delete index template | |
| List all index templates | |
| List all Aliases | |
| Add an Alias | |
| Remove Alias | |
| Delete Alias | |
| Roll over an Alias or data stream | |
| Index template for data stream | |
| Create a data stream | |
| Get information about a data stream | |
| Monitor stats of a data stream | |
| Ingest data into the data stream | |
| Searching a data stream | |
| Delete a data stream | |
| Re-index an Index | |
| Re-index data based on a condition or time range | |
| Re-index and apply the Ingest pipeline. | |
| Check if ISM is set on an INDEX | |
| Retry ISM Policy on an index | |
| Increase the Shard limit for single-node deployments. | |
| Create a new ISM policy | |
| Get specific ISM policy | |
| List all ISM policies | |
| Delete ISM policy | |
| Create ingest-pipeline | |
| Get a specific ingest pipeline | |
| List all ingest pipelines | |
| Delete ingest-pipeline | |
| Simulate ingest-pipeline | |
| Monitor the Ingest pipeline performance | |
| Create rollup-job | |
| Get a specific rollup job | |
| List all rollup-jobs | |
| Delete rollup-job | |
| Create index template | |
| Get index template | |
| Delete index template | |
| List all index templates | |
| List all Aliases | |
| Add an Alias | |
| Remove Alias | |
| Delete Alias | |
| Roll over an Alias or data stream | |
| Index template for data stream | |
| Create a data stream | |
| Get information about a data stream | |
| Monitor stats of a data stream | |
| Ingest data into the data stream | |
| Searching for a data stream | |
| Delete a data stream | |
| Re-index an Index | |
| Re-index data based on a condition or time range. | |
| Re-index and apply the Ingest pipeline. | |
| Check if ISM is set on an INDEX | |
| Retry ISM Policy on an index | |
| Increase the Shard limit for single-node deployments. | |