diff --git a/API_STYLE_GUIDE.md b/API_STYLE_GUIDE.md index 6dc40df017..a6e0551f17 100644 --- a/API_STYLE_GUIDE.md +++ b/API_STYLE_GUIDE.md @@ -115,7 +115,7 @@ Include a table with these columns: Field | Data type | Description :--- | :--- | :--- -#### Example request +## Example request Provide a sentence that describes what is shown in the example, followed by a cut-and-paste-ready API request in JSON format. Make sure that you test the request yourself in the Dashboards Dev Tools console to make sure it works. See the following examples. @@ -139,7 +139,7 @@ POST _reindex } ``` -#### Example response +## Example response Include a JSON example response to show what the API returns. See the following examples. diff --git a/_api-reference/analyze-apis.md b/_api-reference/analyze-apis.md index 10af71c1ad..ac8e9e249f 100644 --- a/_api-reference/analyze-apis.md +++ b/_api-reference/analyze-apis.md @@ -61,7 +61,7 @@ Field | Data type | Description :--- | :--- | :--- text | String or Array of Strings | Text to analyze. If you provide an array of strings, the text is analyzed as a multi-value field. -#### Example requests +## Example requests [Analyze array of text strings](#analyze-array-of-text-strings) diff --git a/_api-reference/cat/cat-aliases.md b/_api-reference/cat/cat-aliases.md index b0c2d7184e..2d5c5c300a 100644 --- a/_api-reference/cat/cat-aliases.md +++ b/_api-reference/cat/cat-aliases.md @@ -15,26 +15,6 @@ has_children: false The CAT aliases operation lists the mapping of aliases to indexes, plus routing and filtering information. -## Example - -```json -GET _cat/aliases?v -``` -{% include copy-curl.html %} - -To limit the information to a specific alias, add the alias name after your query: - -```json -GET _cat/aliases/?v -``` -{% include copy-curl.html %} - -If you want to get information for more than one alias, separate the alias names with commas: - -```json -GET _cat/aliases/alias1,alias2,alias3 -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -55,7 +35,28 @@ Parameter | Type | Description local | Boolean | Whether to return information from the local node only instead of from the cluster manager node. Default is `false`. expand_wildcards | Enum | Expands wildcard expressions to concrete indexes. Combine multiple values with commas. Supported values are `all`, `open`, `closed`, `hidden`, and `none`. Default is `open`. -## Response +## Example requests + +```json +GET _cat/aliases?v +``` +{% include copy-curl.html %} + +To limit the information to a specific alias, add the alias name after your query: + +```json +GET _cat/aliases/?v +``` +{% include copy-curl.html %} + +If you want to get information for more than one alias, separate the alias names with commas: + +```json +GET _cat/aliases/alias1,alias2,alias3 +``` +{% include copy-curl.html %} + +## Example response The following response shows that `alias1` refers to a `movies` index and has a configured filter: diff --git a/_api-reference/cat/cat-allocation.md b/_api-reference/cat/cat-allocation.md index 23ebed79ff..085a755dc1 100644 --- a/_api-reference/cat/cat-allocation.md +++ b/_api-reference/cat/cat-allocation.md @@ -14,26 +14,6 @@ has_children: false The CAT allocation operation lists the allocation of disk space for indexes and the number of shards on each node. -## Example - -```json -GET _cat/allocation?v -``` -{% include copy-curl.html %} - -To limit the information to a specific node, add the node name after your query: - -```json -GET _cat/allocation/ -``` -{% include copy-curl.html %} - -If you want to get information for more than one node, separate the node names with commas: - -```json -GET _cat/allocation/node_name_1,node_name_2,node_name_3 -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -54,7 +34,28 @@ bytes | Byte size | Specify the units for byte size. For example, `7kb` or `6gb` local | Boolean | Whether to return information from the local node only instead of from the cluster manager node. Default is `false`. cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. -## Response +## Example requests + +```json +GET _cat/allocation?v +``` +{% include copy-curl.html %} + +To limit the information to a specific node, add the node name after your query: + +```json +GET _cat/allocation/ +``` +{% include copy-curl.html %} + +If you want to get information for more than one node, separate the node names with commas: + +```json +GET _cat/allocation/node_name_1,node_name_2,node_name_3 +``` +{% include copy-curl.html %} + +## Example response The following response shows that eight shards are allocated to each of the two nodes available: diff --git a/_api-reference/cat/cat-cluster_manager.md b/_api-reference/cat/cat-cluster_manager.md index abf204ce16..d81e334009 100644 --- a/_api-reference/cat/cat-cluster_manager.md +++ b/_api-reference/cat/cat-cluster_manager.md @@ -14,12 +14,6 @@ has_children: false The CAT cluster manager operation lists information that helps identify the elected cluster manager node. -## Example - -``` -GET _cat/cluster_manager?v -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -37,7 +31,14 @@ Parameter | Type | Description :--- | :--- | :--- cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. -## Response +## Example requests + +``` +GET _cat/cluster_manager?v +``` +{% include copy-curl.html %} + +## Example response ```json id | host | ip | node diff --git a/_api-reference/cat/cat-count.md b/_api-reference/cat/cat-count.md index 34baa04dd4..8d0b4fbad2 100644 --- a/_api-reference/cat/cat-count.md +++ b/_api-reference/cat/cat-count.md @@ -15,7 +15,19 @@ redirect_from: The CAT count operation lists the number of documents in your cluster. -## Example + +## Path and HTTP methods + +``` +GET _cat/count?v +GET _cat/count/?v +``` + +## URL parameters + +All CAT count URL parameters are optional. You can specify any of the [common URL parameters]({{site.url}}{{site.baseurl}}/api-reference/cat/index). + +## Example requests ```json GET _cat/count?v @@ -36,19 +48,7 @@ GET _cat/count/index_or_alias_1,index_or_alias_2,index_or_alias_3 ``` {% include copy-curl.html %} -## Path and HTTP methods - -``` -GET _cat/count?v -GET _cat/count/?v -``` - -## URL parameters - -All CAT count URL parameters are optional. You can specify any of the [common URL parameters]({{site.url}}{{site.baseurl}}/api-reference/cat/index). - - -## Response +## Example response The following response shows the overall document count as 1625: diff --git a/_api-reference/cat/cat-field-data.md b/_api-reference/cat/cat-field-data.md index 6481e5cea1..05c720b952 100644 --- a/_api-reference/cat/cat-field-data.md +++ b/_api-reference/cat/cat-field-data.md @@ -8,13 +8,31 @@ redirect_from: - /opensearch/rest-api/cat/cat-field-data/ --- -# CAT fielddata +# CAT Field Data **Introduced 1.0** {: .label .label-purple } -The CAT fielddata operation lists the memory size used by each field per node. +The CAT Field Data operation lists the memory size used by each field per node. -## Example + +## Path and HTTP methods + +``` +GET _cat/fielddata?v +GET _cat/fielddata/?v +``` + +## URL parameters + +All CAT fielddata URL parameters are optional. + +In addition to the [common URL parameters]({{site.url}}{{site.baseurl}}/api-reference/cat/index), you can specify the following parameter: + +Parameter | Type | Description +:--- | :--- | :--- +bytes | Byte size | Specify the units for byte size. For example, `7kb` or `6gb`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/). + +## Example requests ```json GET _cat/fielddata?v @@ -35,24 +53,7 @@ GET _cat/fielddata/field_name_1,field_name_2,field_name_3 ``` {% include copy-curl.html %} -## Path and HTTP methods - -``` -GET _cat/fielddata?v -GET _cat/fielddata/?v -``` - -## URL parameters - -All CAT fielddata URL parameters are optional. - -In addition to the [common URL parameters]({{site.url}}{{site.baseurl}}/api-reference/cat/index), you can specify the following parameter: - -Parameter | Type | Description -:--- | :--- | :--- -bytes | Byte size | Specify the units for byte size. For example, `7kb` or `6gb`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/). - -## Response +## Example response The following response shows the memory size for all fields as 284 bytes: diff --git a/_api-reference/cat/cat-health.md b/_api-reference/cat/cat-health.md index 7767cfbc46..1c400916ad 100644 --- a/_api-reference/cat/cat-health.md +++ b/_api-reference/cat/cat-health.md @@ -15,12 +15,6 @@ redirect_from: The CAT health operation lists the status of the cluster, how long the cluster has been up, the number of nodes, and other useful information that helps you analyze the health of your cluster. -## Example - -```json -GET _cat/health?v -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -38,7 +32,15 @@ Parameter | Type | Description time | Time | Specify the units for time. For example, `5d` or `7h`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/). ts | Boolean | If true, returns HH:MM:SS and Unix epoch timestamps. Default is `true`. -## Response +## Example request + +The following example request give cluster health information for the past 5 days: + +```json +GET _cat/health?v&time=5d +``` + +## Example response ```json GET _cat/health?v&time=5d diff --git a/_api-reference/cat/cat-indices.md b/_api-reference/cat/cat-indices.md index fe9556899e..16c57e5791 100644 --- a/_api-reference/cat/cat-indices.md +++ b/_api-reference/cat/cat-indices.md @@ -14,26 +14,6 @@ redirect_from: The CAT indices operation lists information related to indexes, that is, how much disk space they are using, how many shards they have, their health status, and so on. -## Example - -``` -GET _cat/indices?v -``` -{% include copy-curl.html %} - -To limit the information to a specific index, add the index name after your query. - -``` -GET _cat/indices/?v -``` -{% include copy-curl.html %} - -If you want to get information for more than one index, separate the indexes with commas: - -```json -GET _cat/indices/index1,index2,index3 -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -58,8 +38,29 @@ pri | Boolean | Whether to return information only from the primary shards. Defa time | Time | Specify the units for time. For example, `5d` or `7h`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/). expand_wildcards | Enum | Expands wildcard expressions to concrete indexes. Combine multiple values with commas. Supported values are `all`, `open`, `closed`, `hidden`, and `none`. Default is `open`. +## Example requests + +``` +GET _cat/indices?v +``` +{% include copy-curl.html %} + +To limit the information to a specific index, add the index name after your query. + +``` +GET _cat/indices/?v +``` +{% include copy-curl.html %} + +If you want to get information for more than one index, separate the indexes with commas: + +```json +GET _cat/indices/index1,index2,index3 +``` +{% include copy-curl.html %} + -## Response +## Example response ```json health | status | index | uuid | pri | rep | docs.count | docs.deleted | store.size | pri.store.size diff --git a/_api-reference/cat/cat-nodeattrs.md b/_api-reference/cat/cat-nodeattrs.md index 6b4cc6d92e..b09e164698 100644 --- a/_api-reference/cat/cat-nodeattrs.md +++ b/_api-reference/cat/cat-nodeattrs.md @@ -14,12 +14,6 @@ redirect_from: The CAT nodeattrs operation lists the attributes of custom nodes. -## Example - -``` -GET _cat/nodeattrs?v -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -38,8 +32,17 @@ Parameter | Type | Description local | Boolean | Whether to return information from the local node only instead of from the cluster manager node. Default is `false`. cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. +## Example request + +The following example request returns attributes about custom nodes: + +``` +GET _cat/nodeattrs?v +``` +{% include copy-curl.html %} + -## Response +## Example response ```json node | host | ip | attr | value diff --git a/_api-reference/cat/cat-nodes.md b/_api-reference/cat/cat-nodes.md index 864e5dfdd5..5e7238a0d0 100644 --- a/_api-reference/cat/cat-nodes.md +++ b/_api-reference/cat/cat-nodes.md @@ -16,12 +16,6 @@ The CAT nodes operation lists node-level information, including node roles and l A few important node metrics are `pid`, `name`, `cluster_manager`, `ip`, `port`, `version`, `build`, `jdk`, along with `disk`, `heap`, `ram`, and `file_desc`. -## Example - -``` -GET _cat/nodes?v -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -43,8 +37,17 @@ cluster_manager_timeout | Time | The amount of time to wait for a connection to time | Time | Specify the units for time. For example, `5d` or `7h`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/). include_unloaded_segments | Boolean | Whether to include information from segments not loaded into memory. Default is `false`. +## Example request + +The following example request lists node level information: + +``` +GET _cat/nodes?v +``` +{% include copy-curl.html %} + -## Response +## Example response ```json ip | heap.percent | ram.percent | cpu load_1m | load_5m | load_15m | node.role | node.roles | cluster_manager | name diff --git a/_api-reference/cat/cat-pending-tasks.md b/_api-reference/cat/cat-pending-tasks.md index 748defd06e..ea224670ac 100644 --- a/_api-reference/cat/cat-pending-tasks.md +++ b/_api-reference/cat/cat-pending-tasks.md @@ -15,12 +15,6 @@ redirect_from: The CAT pending tasks operation lists the progress of all pending tasks, including task priority and time in queue. -## Example - -``` -GET _cat/pending_tasks?v -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -40,7 +34,16 @@ local | Boolean | Whether to return information from the local node only instead cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. time | Time | Specify the units for time. For example, `5d` or `7h`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/). -## Response +## Example request + +The following example request lists the progress of all pending node tasks: + +``` +GET _cat/pending_tasks?v +``` +{% include copy-curl.html %} + +## Example response ```json insertOrder | timeInQueue | priority | source diff --git a/_api-reference/cat/cat-plugins.md b/_api-reference/cat/cat-plugins.md index 519c77f27f..358eb70fbf 100644 --- a/_api-reference/cat/cat-plugins.md +++ b/_api-reference/cat/cat-plugins.md @@ -15,12 +15,6 @@ redirect_from: The CAT plugins operation lists the names, components, and versions of the installed plugins. -## Example - -``` -GET _cat/plugins?v -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -39,7 +33,16 @@ Parameter | Type | Description local | Boolean | Whether to return information from the local node only instead of from the cluster manager node. Default is `false`. cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. -## Response +## Example requests + +The following example request lists all installed plugins: + +``` +GET _cat/plugins?v +``` +{% include copy-curl.html %} + +## Example response ```json name component version diff --git a/_api-reference/cat/cat-recovery.md b/_api-reference/cat/cat-recovery.md index da66aa7272..8f251a94e0 100644 --- a/_api-reference/cat/cat-recovery.md +++ b/_api-reference/cat/cat-recovery.md @@ -15,26 +15,6 @@ redirect_from: The CAT recovery operation lists all completed and ongoing index and shard recoveries. -## Example - -``` -GET _cat/recovery?v -``` -{% include copy-curl.html %} - -To see only the recoveries of a specific index, add the index name after your query. - -``` -GET _cat/recovery/?v -``` -{% include copy-curl.html %} - -If you want to get information for more than one index, separate the indexes with commas: - -```json -GET _cat/recovery/index1,index2,index3 -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -55,7 +35,28 @@ bytes | Byte size | Specify the units for byte size. For example, `7kb` or `6gb` detailed | Boolean | Whether to include detailed information about shard recoveries. Default is `false`. time | Time | Specify the units for time. For example, `5d` or `7h`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/). -## Response +## Example requests + +``` +GET _cat/recovery?v +``` +{% include copy-curl.html %} + +To see only the recoveries of a specific index, add the index name after your query. + +``` +GET _cat/recovery/?v +``` +{% include copy-curl.html %} + +If you want to get information for more than one index, separate the indexes with commas: + +```json +GET _cat/recovery/index1,index2,index3 +``` +{% include copy-curl.html %} + +## Example response ```json index | shard | time | type | stage | source_host | source_node | target_host | target_node | repository | snapshot | files | files_recovered | files_percent | files_total | bytes | bytes_recovered | bytes_percent | bytes_total | translog_ops | translog_ops_recovered | translog_ops_percent diff --git a/_api-reference/cat/cat-repositories.md b/_api-reference/cat/cat-repositories.md index c6d62c9c62..f0fc4bb622 100644 --- a/_api-reference/cat/cat-repositories.md +++ b/_api-reference/cat/cat-repositories.md @@ -15,13 +15,6 @@ redirect_from: The CAT repositories operation lists all snapshot repositories for a cluster. -## Example - -``` -GET _cat/repositories?v -``` -{% include copy-curl.html %} - ## Path and HTTP methods ``` @@ -39,8 +32,17 @@ Parameter | Type | Description local | Boolean | Whether to return information from the local node only instead of from the cluster manager node. Default is `false`. cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. +## Example request + +The following example request lists all snapshot repositories in the cluster: + +``` +GET _cat/repositories?v +``` +{% include copy-curl.html %} + -## Response +## Example response ```json id type diff --git a/_api-reference/cat/cat-segment-replication.md b/_api-reference/cat/cat-segment-replication.md index e22012ea66..5900b97a7c 100644 --- a/_api-reference/cat/cat-segment-replication.md +++ b/_api-reference/cat/cat-segment-replication.md @@ -47,11 +47,11 @@ Parameter | Data type | Description `v` | Boolean | If `true`, the response includes column headings. Defaults to `false`. `s` | String | Specifies to sort the results. For example, `s=shardId:desc` sorts by shardId in descending order. -## Example +## Example requests The following examples illustrate various segment replication responses. -#### Example 1: No active segment replication events +### No active segment replication events The following query requests segment replication metrics with column headings for all indexes: @@ -67,7 +67,7 @@ shardId target_node target_host checkpoints_behind bytes_behind current_lag last [index-1][0] runTask-1 127.0.0.1 0 0b 0s 7ms 0 ``` -#### Example 2: Shard ID specified +### Shard ID specified The following query requests segment replication metrics with column headings for shards with the ID `0` from indexes `index1` and `index2`: @@ -84,7 +84,7 @@ shardId target_node target_host checkpoints_behind bytes_behind current_lag last [index-2][0] runTask-1 127.0.0.1 0 0b 0s 5ms 0 ``` -#### Example 3: Detailed response +### Detailed response The following query requests detailed segment replication metrics with column headings for all indexes: @@ -101,7 +101,7 @@ shardId target_node target_host checkpoints_behind bytes_behind current_lag last [index-2][0] runTask-1 127.0.0.1 0 0b 0s 5ms 0 done 7ms 3 100.0% 3664 100.0% 2023-03-16T13:53:33.466Z 2023-03-16T13:53:33.474Z 3 3 3.5kb 3.5kb 0s 1ms 0s 2ms 2ms ``` -#### Example 4: Sorting the results +### Sorting the results The following query requests segment replication metrics with column headings for all indexes, sorted by shard ID in descending order: @@ -118,7 +118,7 @@ shardId target_node target_host checkpoints_behind bytes_behind current_lag [test6][0] runTask-2 127.0.0.1 0 0b 0s 4ms 0 ``` -#### Example 5: Using a metric alias +### Using a metric alias In a request, you can either use a metric's full name or one of its aliases. The following query is the same as the preceding query, but it uses the alias `s` instead of `shardID` for sorting: @@ -127,9 +127,9 @@ GET /_cat/segment_replication?v&s=s:desc ``` {% include copy-curl.html %} -## Response metrics +## Example response metrics -The following table lists the response metrics that are returned for all requests. When referring to a metric in a query parameter, you can provide either the metric's full name or any of its aliases, as shown in the previous [example](#example-5-using-a-metric-alias). +The following table lists the response metrics that are returned for all requests. When referring to a metric in a query parameter, you can provide either the metric's full name or any of its aliases, as shown in the previous [example](#using-a-metric-alias). Metric | Alias | Description :--- | :--- | :--- diff --git a/_api-reference/cat/cat-segments.md b/_api-reference/cat/cat-segments.md index b860486692..cd9eda38be 100644 --- a/_api-reference/cat/cat-segments.md +++ b/_api-reference/cat/cat-segments.md @@ -15,7 +15,25 @@ redirect_from: The cat segments operation lists Lucene segment-level information for each index. -## Example + +## Path and HTTP methods + +``` +GET _cat/segments +``` + +## URL parameters + +All CAT segments URL parameters are optional. + +In addition to the [common URL parameters]({{site.url}}{{site.baseurl}}/api-reference/cat/index), you can specify the following parameters: + +Parameter | Type | Description +:--- | :--- | :--- +bytes | Byte size | Specify the units for byte size. For example, `7kb` or `6gb`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/).. +cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. + +## Example requests ``` GET _cat/segments?v @@ -36,25 +54,7 @@ GET _cat/segments/index1,index2,index3 ``` {% include copy-curl.html %} -## Path and HTTP methods - -``` -GET _cat/segments -``` - -## URL parameters - -All CAT segments URL parameters are optional. - -In addition to the [common URL parameters]({{site.url}}{{site.baseurl}}/api-reference/cat/index), you can specify the following parameters: - -Parameter | Type | Description -:--- | :--- | :--- -bytes | Byte size | Specify the units for byte size. For example, `7kb` or `6gb`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/).. -cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. - - -## Response +## Example response ```json index | shard | prirep | ip | segment | generation | docs.count | docs.deleted | size | size.memory | committed | searchable | version | compound diff --git a/_api-reference/cat/cat-shards.md b/_api-reference/cat/cat-shards.md index 9a727b5b11..b07f11aca3 100644 --- a/_api-reference/cat/cat-shards.md +++ b/_api-reference/cat/cat-shards.md @@ -15,26 +15,6 @@ redirect_from: The CAT shards operation lists the state of all primary and replica shards and how they are distributed. -## Example - -``` -GET _cat/shards?v -``` -{% include copy-curl.html %} - -To see only the information about shards of a specific index, add the index name after your query. - -``` -GET _cat/shards/?v -``` -{% include copy-curl.html %} - -If you want to get information for more than one index, separate the indexes with commas: - -``` -GET _cat/shards/index1,index2,index3 -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -55,8 +35,30 @@ local | Boolean | Whether to return information from the local node only instead cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. time | Time | Specify the units for time. For example, `5d` or `7h`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/). +## Example requests + +The following example requests returns information about shards: + +``` +GET _cat/shards?v +``` +{% include copy-curl.html %} + +To see only the information about shards of a specific index, add the index name after your query. + +``` +GET _cat/shards/?v +``` +{% include copy-curl.html %} + +If you want to get information for more than one index, separate the indexes with commas: + +``` +GET _cat/shards/index1,index2,index3 +``` +{% include copy-curl.html %} -## Response +## Example response ```json index | shard | prirep | state | docs | store | ip | | node diff --git a/_api-reference/cat/cat-snapshots.md b/_api-reference/cat/cat-snapshots.md index 82cb5c1b1f..2e1bd514bf 100644 --- a/_api-reference/cat/cat-snapshots.md +++ b/_api-reference/cat/cat-snapshots.md @@ -15,12 +15,6 @@ redirect_from: The CAT snapshots operation lists all snapshots for a repository. -## Example - -``` -GET _cat/snapshots?v -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -39,8 +33,17 @@ Parameter | Type | Description cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. time | Time | Specify the units for time. For example, `5d` or `7h`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/). +## Example request + +The following example request lists all snapshots: + +``` +GET _cat/snapshots?v +``` +{% include copy-curl.html %} + -## Response +## Example response ```json index | shard | prirep | state | docs | store | ip | | node diff --git a/_api-reference/cat/cat-tasks.md b/_api-reference/cat/cat-tasks.md index 4d2a06cced..7a71b592e7 100644 --- a/_api-reference/cat/cat-tasks.md +++ b/_api-reference/cat/cat-tasks.md @@ -15,13 +15,6 @@ redirect_from: The CAT tasks operation lists the progress of all tasks currently running on your cluster. -## Example - -``` -GET _cat/tasks?v -``` -{% include copy-curl.html %} - ## Path and HTTP methods ``` @@ -41,8 +34,17 @@ detailed | Boolean | Returns detailed task information. (Default: false) parent_task_id | String | Returns tasks with a specified parent task ID (node_id:task_number). Keep empty or set to -1 to return all. time | Time | Specify the units for time. For example, `5d` or `7h`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/opensearch/units/). +## Example request + +The following example request lists all tasks in progress: + +``` +GET _cat/tasks?v +``` +{% include copy-curl.html %} + -## Response +## Example response ```json action | task_id | parent_task_id | type | start_time | timestamp | running_time | ip | node diff --git a/_api-reference/cat/cat-templates.md b/_api-reference/cat/cat-templates.md index d7c7aac90f..ba47ae711d 100644 --- a/_api-reference/cat/cat-templates.md +++ b/_api-reference/cat/cat-templates.md @@ -15,19 +15,6 @@ redirect_from: The CAT templates operation lists the names, patterns, order numbers, and version numbers of index templates. -## Example - -``` -GET _cat/templates?v -``` -{% include copy-curl.html %} - -If you want to get information for a specific template or pattern: - -``` -GET _cat/templates/ -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -47,8 +34,24 @@ Parameter | Type | Description local | Boolean | Whether to return information from the local node only instead of from the cluster manager node. Default is `false`. cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. +## Example requests + +The following example request returns information about all templates: + +``` +GET _cat/templates?v +``` +{% include copy-curl.html %} + +If you want to get information for a specific template or pattern: + +``` +GET _cat/templates/ +``` +{% include copy-curl.html %} + -## Response +## Example response ``` name | index_patterns order version composed_of diff --git a/_api-reference/cat/cat-thread-pool.md b/_api-reference/cat/cat-thread-pool.md index 491b523092..de24052175 100644 --- a/_api-reference/cat/cat-thread-pool.md +++ b/_api-reference/cat/cat-thread-pool.md @@ -14,7 +14,27 @@ redirect_from: The CAT thread pool operation lists the active, queued, and rejected threads of different thread pools on each node. -## Example + +## Path and HTTP methods + +``` +GET _cat/thread_pool +``` + +## URL parameters + +All CAT thread pool URL parameters are optional. + +In addition to the [common URL parameters]({{site.url}}{{site.baseurl}}/api-reference/cat/index), you can specify the following parameters: + +Parameter | Type | Description +:--- | :--- | :--- +local | Boolean | Whether to return information from the local node only instead of from the cluster manager node. Default is `false`. +cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. + +## Example requests + +The following example request gives information about thread pools on all nodes: ``` GET _cat/thread_pool?v @@ -35,25 +55,8 @@ GET _cat/thread_pool/?v ``` {% include copy-curl.html %} -## Path and HTTP methods - -``` -GET _cat/thread_pool -``` - -## URL parameters - -All CAT thread pool URL parameters are optional. - -In addition to the [common URL parameters]({{site.url}}{{site.baseurl}}/api-reference/cat/index), you can specify the following parameters: - -Parameter | Type | Description -:--- | :--- | :--- -local | Boolean | Whether to return information from the local node only instead of from the cluster manager node. Default is `false`. -cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. - -## Response +## Example response ```json node_name name active queue rejected diff --git a/_api-reference/cluster-api/cluster-allocation.md b/_api-reference/cluster-api/cluster-allocation.md index b1b1c266d6..4ec6e27f2b 100644 --- a/_api-reference/cluster-api/cluster-allocation.md +++ b/_api-reference/cluster-api/cluster-allocation.md @@ -17,17 +17,6 @@ The most basic cluster allocation explain request finds an unassigned shard and If you add some options, you can instead get information on a specific shard, including why OpenSearch assigned it to its current node. -## Example - -```json -GET _cluster/allocation/explain?include_yes_decisions=true -{ - "index": "movies", - "shard": 0, - "primary": true -} -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -58,8 +47,20 @@ index | String | The name of the shard's index. primary | Boolean | Whether to provide an explanation for the primary shard (true) or its first replica (false), which share the same shard ID. shard | Integer | The shard ID that you want an explanation for. +## Example request + +```json +GET _cluster/allocation/explain?include_yes_decisions=true +{ + "index": "movies", + "shard": 0, + "primary": true +} +``` +{% include copy-curl.html %} + -## Response +## Example response ```json { diff --git a/_api-reference/cluster-api/cluster-decommission.md b/_api-reference/cluster-api/cluster-decommission.md index 867f58eda0..c707e5390a 100644 --- a/_api-reference/cluster-api/cluster-decommission.md +++ b/_api-reference/cluster-api/cluster-decommission.md @@ -54,7 +54,7 @@ DELETE /_cluster/decommission/awareness ``` {% include copy-curl.html %} -#### Response +#### Example response ```json @@ -74,7 +74,7 @@ GET /_cluster/decommission/awareness/zone/_status ``` {% include copy-curl.html %} -#### Response +#### Example response ```json { diff --git a/_api-reference/cluster-api/cluster-health.md b/_api-reference/cluster-api/cluster-health.md index 73c83d5ee6..7081a1a587 100644 --- a/_api-reference/cluster-api/cluster-health.md +++ b/_api-reference/cluster-api/cluster-health.md @@ -17,16 +17,6 @@ The most basic cluster health request returns a simple status of the health of y To get the status of a specific index, provide the index name. -## Example - -This request waits 50 seconds for the cluster to reach the yellow status or better: - -``` -GET _cluster/health?wait_for_status=yellow&timeout=50s -``` -{% include copy-curl.html %} - -If the cluster health becomes yellow or green before 50 seconds elapse, it returns a response immediately. Otherwise it returns a response as soon as it exceeds the timeout. ## Path and HTTP methods @@ -55,7 +45,18 @@ wait_for_no_initializing_shards | Boolean | Whether to wait until there are no i wait_for_status | Enum | Wait until the cluster health reaches the specified status or better. Supported values are `green`, `yellow`, and `red`. weights | JSON object | Assigns weights to attributes within the request body of the PUT request. Weights can be set in any ration, for example, 2:3:5. In a 2:3:5 ratio with three zones, for every 100 requests sent to the cluster, each zone would receive either 20, 30, or 50 search requests in a random order. When assigned a weight of `0`, the zone does not receive any search traffic. -#### Example request +## Example requests + +The following examples show how to use the cluster health API. + +This request waits 50 seconds for the cluster to reach the yellow status or better: + +``` +GET _cluster/health?wait_for_status=yellow&timeout=50s +``` +{% include copy-curl.html %} + +If the cluster health becomes yellow or green before 50 seconds elapse, it returns a response immediately. Otherwise it returns a response as soon as it exceeds the timeout. The following example request retrieves cluster health for all indexes in the cluster: @@ -64,7 +65,7 @@ GET _cluster/health ``` {% include copy-curl.html %} -#### Example response +## Example response The response contains cluster health information: diff --git a/_api-reference/cluster-api/cluster-settings.md b/_api-reference/cluster-api/cluster-settings.md index 3538339001..ec682ecdbd 100644 --- a/_api-reference/cluster-api/cluster-settings.md +++ b/_api-reference/cluster-api/cluster-settings.md @@ -32,25 +32,6 @@ include_defaults (GET only) | Boolean | Whether to include default settings as p cluster_manager_timeout | Time unit | The amount of time to wait for a response from the cluster manager node. Default is `30 seconds`. timeout (PUT only) | Time unit | The amount of time to wait for a response from the cluster. Default is `30 seconds`. - -#### Example request - -```json -GET _cluster/settings?include_defaults=true -``` -{% include copy-curl.html %} - -#### Example response - -```json -PUT _cluster/settings -{ - "persistent":{ - "action.auto_create_index": false - } -} -``` - ## Request fields The GET operation has no request body options. All cluster setting field parameters are optional. @@ -60,9 +41,24 @@ Not all cluster settings can be updated using the cluster settings API. You will For a listing of all cluster settings, see [Configuring OpenSearch]({{site.url}}{{site.baseurl}}/install-and-configure/configuring-opensearch/index/). -#### Example request -For a PUT operation, the request body must contain `transient` or `persistent`, along with the setting you want to update: +## Example requests + +The following example request show how to use the cluster settings API. + +### Check default cluster settings + +The following example request checks for default cluster settings: + +```json +GET _cluster/settings?include_defaults=true +``` +{% include copy-curl.html %} + +### Update cluster setting + +The following example updates the `cluster.max_shards_per_node` setting. For a PUT operation, the request body must contain `transient` or `persistent`, along with the setting you want to update: + ```json PUT _cluster/settings @@ -76,7 +72,9 @@ PUT _cluster/settings For more information about transient settings, persistent settings, and precedence, see [OpenSearch configuration]({{site.url}}{{site.baseurl}}/install-and-configure/configuring-opensearch/). -#### Example response +## Example response + +The following example response shows that the persistent cluster setting, `max_shard_per_node`, has been updated: ```json { diff --git a/_api-reference/cluster-api/cluster-stats.md b/_api-reference/cluster-api/cluster-stats.md index 8f8b585a6a..fb0ade2c6b 100644 --- a/_api-reference/cluster-api/cluster-stats.md +++ b/_api-reference/cluster-api/cluster-stats.md @@ -15,12 +15,6 @@ redirect_from: The cluster stats API operation returns statistics about your cluster. -## Example - -```json -GET _cluster/stats/nodes/_cluster_manager -``` -{% include copy-curl.html %} ## Path and HTTP methods @@ -41,7 +35,16 @@ Parameter | Type | Description Although the `master` node is now called `cluster_manager` for version 2.0, we retained the `master` field for backwards compatibility. If you have a node that has either a `master` role or a `cluster_manager` role, the `count` increases for both fields by 1. To see an example node count increase, see the Response sample. {: .note } -## Response +## Example request + +The following example requests returns information about the cluster manager node: + +```json +GET _cluster/stats/nodes/_cluster_manager +``` +{% include copy-curl.html %} + +## Example response ```json { diff --git a/_api-reference/document-apis/bulk.md b/_api-reference/document-apis/bulk.md index a020fc459d..a9833a701f 100644 --- a/_api-reference/document-apis/bulk.md +++ b/_api-reference/document-apis/bulk.md @@ -134,7 +134,7 @@ All actions support the same metadata: `_index`, `_id`, and `_require_alias`. If { "script" : { "source": "ctx._source.title = \"World War Z\"" } } ``` -## Response +## Example response In the response, pay particular attention to the top-level `errors` boolean. If true, you can iterate over the individual actions for more detailed information. diff --git a/_api-reference/document-apis/delete-by-query.md b/_api-reference/document-apis/delete-by-query.md index 6f4104c254..64da909aad 100644 --- a/_api-reference/document-apis/delete-by-query.md +++ b/_api-reference/document-apis/delete-by-query.md @@ -88,7 +88,7 @@ To search your index for specific documents, you must include a [query]({{site.u } ``` -## Response +## Example response ```json { "took": 143, diff --git a/_api-reference/document-apis/delete-document.md b/_api-reference/document-apis/delete-document.md index c3dea2f7e1..ece99a28ca 100644 --- a/_api-reference/document-apis/delete-document.md +++ b/_api-reference/document-apis/delete-document.md @@ -42,7 +42,7 @@ version_type | Enum | Retrieves a specifically typed document. Available options wait_for_active_shards | String | The number of active shards that must be available before OpenSearch processes the delete request. Default is 1 (only the primary shard). Set to `all` or a positive integer. Values greater than 1 require replicas. For example, if you specify a value of 3, the index must have two replicas distributed across two additional nodes for the operation to succeed. | No -## Response +## Example response ```json { "_index": "sample-index1", diff --git a/_api-reference/document-apis/get-documents.md b/_api-reference/document-apis/get-documents.md index 3eaeb507d4..d493df136b 100644 --- a/_api-reference/document-apis/get-documents.md +++ b/_api-reference/document-apis/get-documents.md @@ -49,7 +49,7 @@ version | Integer | The version of the document to return, which must match the version_type | Enum | Retrieves a specifically typed document. Available options are `external` (retrieve the document if the specified version number is greater than the document's current version) and `external_gte` (retrieve the document if the specified version number is greater than or equal to the document's current version). For example, to retrieve version 3 of a document, use `/_doc/1?version=3&version_type=external`. -## Response +## Example response ```json { "_index": "sample-index1", diff --git a/_api-reference/document-apis/index-document.md b/_api-reference/document-apis/index-document.md index d131a2f50e..a506e2d9d8 100644 --- a/_api-reference/document-apis/index-document.md +++ b/_api-reference/document-apis/index-document.md @@ -110,7 +110,7 @@ Your request body must contain the information you want to index. } ``` -## Response +## Example response ```json { "_index": "sample-index", diff --git a/_api-reference/document-apis/multi-get.md b/_api-reference/document-apis/multi-get.md index 2d3246fa58..b267b8f3ac 100644 --- a/_api-reference/document-apis/multi-get.md +++ b/_api-reference/document-apis/multi-get.md @@ -54,7 +54,11 @@ _source.excludes | Array | Specifies which fields to exclude in the query respon ids | Array | IDs of the documents to retrieve. Only allowed when an index is specified in the URL. | No -#### Example without specifying index in URL +## Example requests + +### Specify an index in the request body + +The following example requests does specifies an index in the request body: ```json GET _mget @@ -76,7 +80,9 @@ GET _mget ``` {% include copy-curl.html %} -#### Example of specifying index in URL +### Specify an index the URL + +The following example specifies an index in the URL: ```json GET sample-index1/_mget @@ -95,7 +101,10 @@ GET sample-index1/_mget ``` {% include copy-curl.html %} -#### Example Response +## Example response + +The following example response returns information about multiple documents: + ```json { "docs": [ diff --git a/_api-reference/document-apis/reindex.md b/_api-reference/document-apis/reindex.md index c2afa347e1..8ac1c48be4 100644 --- a/_api-reference/document-apis/reindex.md +++ b/_api-reference/document-apis/reindex.md @@ -81,7 +81,7 @@ pipeline | Which ingest pipeline to utilize during the reindex. script | A script that OpenSearch uses to apply transformations to the data during the reindex operation. lang | The scripting language. Valid options are `painless`, `expression`, `mustache`, and `java`. -## Response +## Example response ```json { "took": 28829, diff --git a/_api-reference/document-apis/update-by-query.md b/_api-reference/document-apis/update-by-query.md index 217ae69550..09b3bd599f 100644 --- a/_api-reference/document-apis/update-by-query.md +++ b/_api-reference/document-apis/update-by-query.md @@ -102,7 +102,7 @@ To update your indexes and documents by query, you must include a [query]({{site } ``` -## Response +## Example response ```json { "took": 21, diff --git a/_api-reference/document-apis/update-document.md b/_api-reference/document-apis/update-document.md index 3da7030fa5..3f951b5adf 100644 --- a/_api-reference/document-apis/update-document.md +++ b/_api-reference/document-apis/update-document.md @@ -195,7 +195,7 @@ After the upsert operation, the document's `first_name` and `last_name` fields a } ``` -## Response +## Example response ```json { "_index": "sample-index1", diff --git a/_api-reference/index-apis/alias.md b/_api-reference/index-apis/alias.md index a38a3798a4..ebd7bdedfd 100644 --- a/_api-reference/index-apis/alias.md +++ b/_api-reference/index-apis/alias.md @@ -75,7 +75,7 @@ routing | String | Used to assign a custom value to a shard for specific operati index_routing | String | Assigns a custom value to a shard only for index operations. | No search_routing | String | Assigns a custom value to a shard only for search operations. | No -## Response +## Example response ```json { diff --git a/_api-reference/index-apis/clear-index-cache.md b/_api-reference/index-apis/clear-index-cache.md index 55a5ce85d5..9bf873301d 100644 --- a/_api-reference/index-apis/clear-index-cache.md +++ b/_api-reference/index-apis/clear-index-cache.md @@ -38,11 +38,11 @@ All query parameters are optional. | query | Boolean | If `true`, clears the query cache. Defaults to `true`. | | request | Boolean | If `true`, clears the request cache. Defaults to `true`. | -#### Example requests +## Example requests The following example requests show multiple clear cache API uses. -##### Clear a specific cache +### Clear a specific cache The following request clears the fields cache only: @@ -69,7 +69,7 @@ POST /my-index/_cache/clear?request=true ``` {% include copy-curl.html %} -#### Clear the cache for specific fields +### Clear the cache for specific fields The following request clears the fields caches of `fielda` and `fieldb`: @@ -78,7 +78,7 @@ POST /my-index/_cache/clear?fields=fielda,fieldb ``` {% include copy-curl.html %} -#### Clear caches for specific data streams or indexes +### Clear caches for specific data streams or indexes The following request clears the cache for two specific indexes: @@ -96,14 +96,14 @@ POST /_cache/clear ``` {% include copy-curl.html %} -#### Clear unused entries from the cache on search-capable nodes +### Clear unused entries from the cache on search-capable nodes ```json POST /*/_cache/clear?file=true ``` {% include copy-curl.html %} -#### Example response +## Example response The `POST /books,hockey/_cache/clear` request returns the following fields: diff --git a/_api-reference/index-apis/clone.md b/_api-reference/index-apis/clone.md index 60228b5894..c1496cbaf8 100644 --- a/_api-reference/index-apis/clone.md +++ b/_api-reference/index-apis/clone.md @@ -66,7 +66,25 @@ task_execution_timeout | Time | The explicit task execution timeout. Only useful The clone index API operation creates a new target index, so you can specify any [index settings]({{site.url}}{{site.baseurl}}/im-plugin/index-settings/) and [aliases]({{site.url}}{{site.baseurl}}/opensearch/index-alias/) to apply to the target index. -## Response +## Example request + +```json +PUT /sample-index1/_clone/cloned-index1 +{ + "settings": { + "index": { + "number_of_shards": 2, + "number_of_replicas": 1 + } + }, + "aliases": { + "sample-alias1": {} + } +} +``` +{% include copy-curl.html %} + +## Example response ```json { diff --git a/_api-reference/index-apis/close-index.md b/_api-reference/index-apis/close-index.md index 7e43198d37..865d17d90a 100644 --- a/_api-reference/index-apis/close-index.md +++ b/_api-reference/index-apis/close-index.md @@ -41,7 +41,7 @@ cluster_manager_timeout | Time | How long to wait for a connection to the cluste timeout | Time | How long to wait for a response from the cluster. Default is `30s`. -## Response +## Example response ```json { "acknowledged": true, diff --git a/_api-reference/index-apis/create-index.md b/_api-reference/index-apis/create-index.md index 53d2dc28f9..ff5d7dbda5 100644 --- a/_api-reference/index-apis/create-index.md +++ b/_api-reference/index-apis/create-index.md @@ -52,7 +52,7 @@ timeout | Time | How long to wait for the request to return. Default is `30s`. As part of your request, you can optionally specify [index settings]({{site.url}}{{site.baseurl}}/im-plugin/index-settings/), [mappings]({{site.url}}{{site.baseurl}}/field-types/index/), and [aliases]({{site.url}}{{site.baseurl}}/opensearch/index-alias/) for your newly created index. -#### Example request +## Example request ```json PUT /sample-index1 diff --git a/_api-reference/index-apis/delete-index.md b/_api-reference/index-apis/delete-index.md index 20e5c51c93..ad00eb7eca 100644 --- a/_api-reference/index-apis/delete-index.md +++ b/_api-reference/index-apis/delete-index.md @@ -38,7 +38,7 @@ cluster_manager_timeout | Time | How long to wait for a connection to the cluste timeout | Time | How long to wait for the response to return. Default is `30s`. -## Response +## Example response ```json { "acknowledged": true diff --git a/_api-reference/index-apis/exists.md b/_api-reference/index-apis/exists.md index 429ac40745..351e2f2088 100644 --- a/_api-reference/index-apis/exists.md +++ b/_api-reference/index-apis/exists.md @@ -40,6 +40,6 @@ ignore_unavailable | Boolean | If true, OpenSearch does not search for missing o local | Boolean | Whether to return information from only the local node instead of from the cluster manager node. Default is `false`. -## Response +## Example response The index exists API operation returns only one of two possible response codes: `200` -- the index exists, and `404` -- the index does not exist. diff --git a/_api-reference/index-apis/force-merge.md b/_api-reference/index-apis/force-merge.md index 6c2a61bef3..ce7501ebe3 100644 --- a/_api-reference/index-apis/force-merge.md +++ b/_api-reference/index-apis/force-merge.md @@ -74,42 +74,56 @@ The following table lists the available query parameters. All query parameters a | `only_expunge_deletes` | Boolean | If `true`, the merge operation only expunges segments containing a certain percentage of deleted documents. The percentage is 10% by default and is configurable in the `index.merge.policy.expunge_deletes_allowed` setting. Prior to OpenSearch 2.12, `only_expunge_deletes` ignored the `index.merge.policy.max_merged_segment` setting. Starting with OpenSearch 2.12, using `only_expunge_deletes` does not produce segments larger than `index.merge.policy.max_merged_segment` (by default, 5 GB). For more information, see [Deleted documents](#deleted-documents). Default is `false`. | | `primary_only` | Boolean | If set to `true`, then the merge operation is performed only on the primary shards of an index. This can be useful when you want to take a snapshot of the index after the merge is complete. Snapshots only copy segments from the primary shards. Merging the primary shards can reduce resource consumption. Default is `false`. | -#### Example request: Force merge a specific index +## Example requests + +The following examples show how to use the Force merge API. + +### Force merge a specific index + +The following example force merges a specific index: ```json POST /testindex1/_forcemerge ``` {% include copy-curl.html %} -#### Example request: Force merge multiple indexes +### Force merge multiple indexes + +The following example force merges multiple indexes: ```json POST /testindex1,testindex2/_forcemerge ``` {% include copy-curl.html %} -#### Example request: Force merge all indexes +### Force merge all indexes + +The following example force merges all indexes: ```json POST /_forcemerge ``` {% include copy-curl.html %} -#### Example request: Force merge a data stream's backing indexes into one segment +### Force merge a data stream's backing indexes into one segment + +The following example force merges a data stream's backing indexes into one segment: ```json POST /.testindex-logs/_forcemerge?max_num_segments=1 ``` {% include copy-curl.html %} -#### Example request: Force merge primary shards +### Force merge primary shards + +The following example force merges an index's primary shards: ```json POST /.testindex-logs/_forcemerge?primary_only=true ``` {% include copy-curl.html %} -#### Example response +## Example response ```json { diff --git a/_api-reference/index-apis/get-index.md b/_api-reference/index-apis/get-index.md index 733110d63a..e2d2d85c65 100644 --- a/_api-reference/index-apis/get-index.md +++ b/_api-reference/index-apis/get-index.md @@ -41,7 +41,7 @@ local | Boolean | Whether to return information from only the local node instead cluster_manager_timeout | Time | How long to wait for a connection to the cluster manager node. Default is `30s`. -## Response +## Example response ```json { "sample-index1": { diff --git a/_api-reference/index-apis/get-settings.md b/_api-reference/index-apis/get-settings.md index c41b25b4f5..94cb4a7c6c 100644 --- a/_api-reference/index-apis/get-settings.md +++ b/_api-reference/index-apis/get-settings.md @@ -45,7 +45,7 @@ ignore_unavailable | Boolean | If true, OpenSearch does not include missing or c local | Boolean | Whether to return information from the local node only instead of the cluster manager node. Default is `false`. cluster_manager_timeout | Time | How long to wait for a connection to the cluster manager node. Default is `30s`. -## Response +## Example response ```json { diff --git a/_api-reference/index-apis/open-index.md b/_api-reference/index-apis/open-index.md index 12381aa8c6..0d8ef62282 100644 --- a/_api-reference/index-apis/open-index.md +++ b/_api-reference/index-apis/open-index.md @@ -43,7 +43,7 @@ wait_for_completion | Boolean | When set to `false`, the request returns immedia task_execution_timeout | Time | The explicit task execution timeout. Only useful when wait_for_completion is set to `false`. Default is `1h`. -## Response +## Example response ```json { "acknowledged": true, diff --git a/_api-reference/index-apis/split.md b/_api-reference/index-apis/split.md index 03b2f742d1..ad13bffbba 100644 --- a/_api-reference/index-apis/split.md +++ b/_api-reference/index-apis/split.md @@ -66,7 +66,7 @@ task_execution_timeout | Time | The explicit task execution timeout. Only useful The split index API operation creates a new target index, so you can specify any [index settings]({{site.url}}{{site.baseurl}}/im-plugin/index-settings/) and [aliases]({{site.url}}{{site.baseurl}}/opensearch/index-alias/) to apply to the target index. -## Response +## Example response ```json { diff --git a/_api-reference/index-apis/stats.md b/_api-reference/index-apis/stats.md index 8ccd624de1..7310298594 100644 --- a/_api-reference/index-apis/stats.md +++ b/_api-reference/index-apis/stats.md @@ -71,49 +71,65 @@ Parameter | Data type | Description `include_segment_file_sizes` | Boolean | Specifies whether to report the aggregated disk usage of each Lucene index file. Only applies to `segments` statistics. Default is `false`. `include_unloaded_segments` | Boolean | Specifies whether to include information from segments that are not loaded into memory. Default is `false`. -#### Example request: One index +## Example requests + +The following example requests show how to use the Index Stats API. + +### One index + +The following example returns index stats for a single index: ```json GET /testindex/_stats ``` {% include copy-curl.html %} -#### Example request: Comma-separated list of indexes +### Comma-separated list of indexes + +The following example returns stats for multiple indexes: ```json GET /testindex1,testindex2/_stats ``` {% include copy-curl.html %} -#### Example request: Wildcard expression +### Wildcard expression + +The following example returns starts about any index that starts with `testindex`: ```json GET /testindex*/_stats ``` {% include copy-curl.html %} -#### Example request: Specific stats +### Specific stats + +The following example returns index stats related to the index and flush operations: ```json GET /testindex/_stats/refresh,flush ``` {% include copy-curl.html %} -#### Example request: Expand wildcards +### Expand wildcards + +The following example expands all wildcards related to index stats: ```json GET /testindex*/_stats?expand_wildcards=open,hidden ``` {% include copy-curl.html %} -#### Example request: Shard-level statistics +### Shard-level statistics + +The following example returns shard level stats about a test index: ```json GET /testindex/_stats?level=shards ``` {% include copy-curl.html %} -#### Example response +## Example response By default, the returned statistics are aggregated in the `primaries` and `total` aggregations. The `primaries` aggregation contains statistics for the primary shards. The `total` aggregation contains statistics for both primary and replica shards. The following is an example Index Stats API response: diff --git a/_api-reference/nodes-apis/nodes-hot-threads.md b/_api-reference/nodes-apis/nodes-hot-threads.md index 3fb6ff65ea..f5e014dd6d 100644 --- a/_api-reference/nodes-apis/nodes-hot-threads.md +++ b/_api-reference/nodes-apis/nodes-hot-threads.md @@ -46,14 +46,14 @@ ignore_idle_threads | Boolean | Don’t show threads that are in known idle st type | String | Supported thread types are `cpu`, `wait`, or `block`. Defaults to `cpu`. timeout | Time | Sets the time limit for node response. Default value is `30s`. -#### Example request +## Example request ```json GET /_nodes/hot_threads ``` {% include copy-curl.html %} -#### Example response +## Example response ```bash ::: {opensearch}{F-ByTQzVQ3GQeYzQJArJGQ}{GxbcLdCATPWggOuQHJAoCw}{127.0.0.1}{127.0.0.1:9300}{dimr}{shard_indexing_pressure_enabled=true} @@ -65,7 +65,7 @@ GET /_nodes/hot_threads org.opensearch.performanceanalyzer.collectors.ScheduledMetricCollectorsExecutor.run(ScheduledMetricCollectorsExecutor.java:100) ``` -## Response +## Example response Unlike the majority of OpenSearch API responses, this response is in a text format. diff --git a/_api-reference/nodes-apis/nodes-info.md b/_api-reference/nodes-apis/nodes-info.md index d7c810410e..a8953505ff 100644 --- a/_api-reference/nodes-apis/nodes-info.md +++ b/_api-reference/nodes-apis/nodes-info.md @@ -79,7 +79,7 @@ Parameter | Type | Description flat_settings| Boolean | Specifies whether to return the `settings` object of the response in flat format. Default is `false`. timeout | Time | Sets the time limit for node response. Default value is `30s`. -#### Example request +## Example request The following query requests the `process` and `transport` metrics from the cluster manager node: @@ -88,7 +88,7 @@ GET /_nodes/cluster_manager:true/process,transport ``` {% include copy-curl.html %} -#### Example response +## Example response The response contains the metric groups specified in the `` request parameter (in this case, `process` and `transport`): diff --git a/_api-reference/nodes-apis/nodes-reload-secure.md b/_api-reference/nodes-apis/nodes-reload-secure.md index 52b2ef67ab..b4be66ddd4 100644 --- a/_api-reference/nodes-apis/nodes-reload-secure.md +++ b/_api-reference/nodes-apis/nodes-reload-secure.md @@ -36,7 +36,7 @@ The request may include an optional object containing the password for the OpenS } ``` -#### Example request +## Example request The following is an example API request: @@ -45,7 +45,7 @@ POST _nodes/reload_secure_settings ``` {% include copy-curl.html %} -#### Example response +## Example response The following is an example response: diff --git a/_api-reference/nodes-apis/nodes-stats.md b/_api-reference/nodes-apis/nodes-stats.md index ca6810b961..2ccea54390 100644 --- a/_api-reference/nodes-apis/nodes-stats.md +++ b/_api-reference/nodes-apis/nodes-stats.md @@ -118,14 +118,14 @@ level | String | Specifies whether statistics for the `indices` metric are aggre timeout | Time | Sets the time limit for node response. Default is `30s`. include_segment_file_sizes | Boolean | If segment statistics are requested, this field specifies to return the aggregated disk usage of every Lucene index file. Default is `false`. -#### Example request +## Example request ```json GET _nodes/stats/ ``` {% include copy-curl.html %} -#### Example response +## Example response Select the arrow to view the example response. diff --git a/_api-reference/nodes-apis/nodes-usage.md b/_api-reference/nodes-apis/nodes-usage.md index 532ddb626b..355b7f8ff2 100644 --- a/_api-reference/nodes-apis/nodes-usage.md +++ b/_api-reference/nodes-apis/nodes-usage.md @@ -38,7 +38,7 @@ Parameter | Type | Description timeout | Time | Sets the time limit for a response from the node. Default is `30s`. cluster_manager_timeout | Time | Sets the time limit for a response from the cluster manager. Default is `30s`. -#### Example request +## Example request The following request returns usage details for all nodes: @@ -47,7 +47,7 @@ GET _nodes/usage ``` {% include copy-curl.html %} -#### Example response +## Example response The following is an example response: diff --git a/_api-reference/profile.md b/_api-reference/profile.md index 94c7857b80..4f8c69db9c 100644 --- a/_api-reference/profile.md +++ b/_api-reference/profile.md @@ -26,7 +26,7 @@ A slice is the unit of work that can be executed by a thread. Each query can be In general, the max/min/avg slice time captures statistics across all slices for a timing type. For example, when profiling aggregations, the `max_slice_time_in_nanos` field in the `aggregations` section shows the maximum time consumed by the aggregation operation and its children across all slices. -#### Example request: Non-concurrent search +## Example request: Non-concurrent search To use the Profile API, include the `profile` parameter set to `true` in the search request sent to the `_search` endpoint: diff --git a/_api-reference/rank-eval.md b/_api-reference/rank-eval.md index 04fd3cf5c0..881ff3a22b 100644 --- a/_api-reference/rank-eval.md +++ b/_api-reference/rank-eval.md @@ -45,7 +45,7 @@ ignore_unlabeled | Defaults to `false`. Unlabeled documents are ignored when set template_id | Template ID. params | Parameters used in the template. -#### Example request +## Example request ````json GET shakespeare/_rank_eval @@ -76,7 +76,7 @@ GET shakespeare/_rank_eval ```` {% include copy-curl.html %} -#### Example response +## Example response ````json { diff --git a/_api-reference/script-apis/create-stored-script.md b/_api-reference/script-apis/create-stored-script.md index 04a73a205a..0a915cd836 100644 --- a/_api-reference/script-apis/create-stored-script.md +++ b/_api-reference/script-apis/create-stored-script.md @@ -47,7 +47,7 @@ All parameters are optional. | lang | String | Scripting language. Required. | | source | String or Object | Required.

For scripts, a string with the contents of the script.

For search templates, an object that defines the search template. Supports the same parameters as the [Search]({{site.url}}{{site.baseurl}}/api-reference/search) API request body. Search templates also support Mustache variables. | -#### Example request +## Example request The sample uses an index called `books` with the following documents: @@ -117,7 +117,7 @@ PUT _scripts/my-first-script See [Execute Painless stored script]({{site.url}}{{site.baseurl}}/api-reference/script-apis/exec-stored-script/) for information about running the script. -#### Example response +## Example response The `PUT _scripts/my-first-script` request returns the following field: diff --git a/_api-reference/script-apis/delete-script.md b/_api-reference/script-apis/delete-script.md index 363b0152df..fe9c272acc 100644 --- a/_api-reference/script-apis/delete-script.md +++ b/_api-reference/script-apis/delete-script.md @@ -26,7 +26,7 @@ Path parameters are optional. | cluster_manager_timeout | Time | Amount of time to wait for a connection to the cluster manager. Optional, defaults to `30s`. | | timeout | Time | The period of time to wait for a response. If a response is not received before the timeout value, the request will be dropped. -#### Example request +## Example request The following request deletes the `my-first-script` script: @@ -35,7 +35,7 @@ DELETE _scripts/my-script ```` {% include copy-curl.html %} -#### Example response +## Example response The `DELETE _scripts/my-first-script` request returns the following field: diff --git a/_api-reference/script-apis/exec-script.md b/_api-reference/script-apis/exec-script.md index 4ecb6a37fc..b6476be980 100644 --- a/_api-reference/script-apis/exec-script.md +++ b/_api-reference/script-apis/exec-script.md @@ -26,7 +26,7 @@ POST /_scripts/painless/_execute | context | A context for the script. Optional. Default is `painless_test`. | | context_setup | Specifies additional parameters for the context. Optional.| -#### Example request +## Example request The following request uses the default `painless_context` for the script: @@ -44,7 +44,7 @@ GET /_scripts/painless/_execute ``` {% include copy-curl.html %} -#### Example response +## Example response The response contains the average of two script parameters: diff --git a/_api-reference/script-apis/exec-stored-script.md b/_api-reference/script-apis/exec-stored-script.md index 7525ec81a4..a7de3b5274 100644 --- a/_api-reference/script-apis/exec-stored-script.md +++ b/_api-reference/script-apis/exec-stored-script.md @@ -21,7 +21,7 @@ OpenSearch provides several ways to run a script; the following sections show ho | script_fields | Object | Fields to include in output. | | script | Object | ID of the script that produces a value for a field. | -#### Example request +## Example request The following request runs the stored script that was created in [Create or update stored script]({{site.url}}{{site.baseurl}}/api-reference/script-apis/create-stored-script/). The script sums the ratings for each book and displays the sum in the `total_ratings` field in the output. diff --git a/_api-reference/script-apis/get-script-contexts.md b/_api-reference/script-apis/get-script-contexts.md index 40a155955f..85421128a1 100644 --- a/_api-reference/script-apis/get-script-contexts.md +++ b/_api-reference/script-apis/get-script-contexts.md @@ -11,14 +11,14 @@ nav_order: 5 Retrieves all contexts for stored scripts. -#### Example request +## Example request ````json GET _script_context ```` {% include copy-curl.html %} -#### Example response +## Example response The `GET _script_context` request returns the following fields: diff --git a/_api-reference/script-apis/get-script-language.md b/_api-reference/script-apis/get-script-language.md index f84b7db4a0..76414d52ea 100644 --- a/_api-reference/script-apis/get-script-language.md +++ b/_api-reference/script-apis/get-script-language.md @@ -11,14 +11,14 @@ nav_order: 6 The get script language API operation retrieves all supported script languages and the contexts in which they may be used. -#### Example request +## Example request ```json GET _script_language ``` {% include copy-curl.html %} -#### Example response +## Example response The `GET _script_language` request returns the available contexts for each language: diff --git a/_api-reference/script-apis/get-stored-script.md b/_api-reference/script-apis/get-stored-script.md index cc681cd0f4..d7987974d3 100644 --- a/_api-reference/script-apis/get-stored-script.md +++ b/_api-reference/script-apis/get-stored-script.md @@ -23,7 +23,7 @@ Retrieves a stored script. :--- | :--- | :--- | cluster_manager_timeout | Time | Amount of time to wait for a connection to the cluster manager. Optional, defaults to `30s`. | -#### Example request +## Example request The following retrieves the `my-first-script` stored script. @@ -32,7 +32,7 @@ GET _scripts/my-first-script ```` {% include copy-curl.html %} -#### Example response +## Example response The `GET _scripts/my-first-script` request returns the following fields: diff --git a/_api-reference/scroll.md b/_api-reference/scroll.md index cee599902d..b940c90d86 100644 --- a/_api-reference/scroll.md +++ b/_api-reference/scroll.md @@ -106,7 +106,7 @@ scroll | Time | Specifies the amount of time the search context is maintained. scroll_id | String | The scroll ID for the search. rest_total_hits_as_int | Boolean | Whether the `hits.total` property is returned as an integer (`true`) or an object (`false`). Default is `false`. -## Response +## Example response ```json { diff --git a/_api-reference/snapshots/create-repository.md b/_api-reference/snapshots/create-repository.md index 54807b85d1..8ee7885ca8 100644 --- a/_api-reference/snapshots/create-repository.md +++ b/_api-reference/snapshots/create-repository.md @@ -48,7 +48,7 @@ Request field | Description `remote_store_index_shallow_copy` | Boolean | Determines whether the snapshot of the remote store indexes are captured as a shallow copy. Default is `false`. `readonly` | Whether the repository is read-only. Useful when migrating from one cluster (`"readonly": false` when registering) to another cluster (`"readonly": true` when registering). Optional. -#### Example request +## Example request The following example registers an `fs` repository using the local directory `/mnt/snapshots` as `location`. @@ -85,7 +85,7 @@ Request field | Description For the `base_path` parameter, do not enter the `s3://` prefix when entering your S3 bucket details. Only the name of the bucket is required. {: .note} -#### Example request +## Example request The following request registers a new S3 repository called `my-opensearch-repo` in an existing bucket called `my-open-search-bucket`. By default, all snapshots are stored in the `my/snapshot/directory`. @@ -101,7 +101,7 @@ PUT /_snapshot/my-opensearch-repo ``` {% include copy-curl.html %} -#### Example response +## Example response Upon success, the following JSON object is returned: diff --git a/_api-reference/snapshots/create-snapshot.md b/_api-reference/snapshots/create-snapshot.md index 6334878d8c..d4c9ef8219 100644 --- a/_api-reference/snapshots/create-snapshot.md +++ b/_api-reference/snapshots/create-snapshot.md @@ -46,7 +46,7 @@ Field | Data type | Description `include_global_state` | Boolean | Whether to include cluster state in the snapshot. Default is `true`. `partial` | Boolean | Whether to allow partial snapshots. Default is `false`, which fails the entire snapshot if one or more shards fails to stor -#### Example requests +## Example requests ##### Request without a body @@ -72,7 +72,7 @@ PUT _snapshot/my-s3-repository/2 ``` {% include copy-curl.html %} -#### Example responses +## Example responses Upon success, the response content depends on whether you include the `wait_for_completion` query parameter. diff --git a/_api-reference/snapshots/delete-snapshot-repository.md b/_api-reference/snapshots/delete-snapshot-repository.md index 385205a5df..1fadc21207 100644 --- a/_api-reference/snapshots/delete-snapshot-repository.md +++ b/_api-reference/snapshots/delete-snapshot-repository.md @@ -21,7 +21,7 @@ Parameter | Data type | Description :--- | :--- | :--- repository | String | Repository to delete. | -#### Example request +## Example request The following request deletes the `my-opensearch-repo` repository: @@ -30,7 +30,7 @@ DELETE _snapshot/my-opensearch-repo ```` {% include copy-curl.html %} -#### Example response +## Example response Upon success, the response returns the following JSON object: diff --git a/_api-reference/snapshots/delete-snapshot.md b/_api-reference/snapshots/delete-snapshot.md index e4232c20ec..d231adf74a 100644 --- a/_api-reference/snapshots/delete-snapshot.md +++ b/_api-reference/snapshots/delete-snapshot.md @@ -24,7 +24,7 @@ Parameter | Data type | Description repository | String | Repostory that contains the snapshot. | snapshot | String | Snapshot to delete. | -#### Example request +## Example request The following request deletes a snapshot called `my-first-snapshot` from the `my-opensearch-repo` repository: @@ -33,7 +33,7 @@ DELETE _snapshot/my-opensearch-repo/my-first-snapshot ``` {% include copy-curl.html %} -#### Example response +## Example response Upon success, the response returns the following JSON object: diff --git a/_api-reference/snapshots/get-snapshot-repository.md b/_api-reference/snapshots/get-snapshot-repository.md index 501d0785dd..6617106059 100644 --- a/_api-reference/snapshots/get-snapshot-repository.md +++ b/_api-reference/snapshots/get-snapshot-repository.md @@ -29,7 +29,7 @@ You can also get details about a snapshot during and after snapshot creation. Se | local | Boolean | Whether to get information from the local node. Optional, defaults to `false`.| | cluster_manager_timeout | Time | Amount of time to wait for a connection to the cluster manager node. Optional, defaults to 30 seconds. | -#### Example request +## Example request The following request retrieves information for the `my-opensearch-repo` repository: @@ -38,7 +38,7 @@ GET /_snapshot/my-opensearch-repo ```` {% include copy-curl.html %} -#### Example response +## Example response Upon success, the response returns repositry information. This sample is for an `s3` repository type. diff --git a/_api-reference/snapshots/get-snapshot-status.md b/_api-reference/snapshots/get-snapshot-status.md index 6f8320d0b0..c7f919bcb3 100644 --- a/_api-reference/snapshots/get-snapshot-status.md +++ b/_api-reference/snapshots/get-snapshot-status.md @@ -42,7 +42,7 @@ Using the API to return state for other than currently running snapshots can be :--- | :--- | :--- | ignore_unavailable | Boolean | How to handles requests for unavailable snapshots. If `false`, the request returns an error for unavailable snapshots. If `true`, the request ignores unavailable snapshots, such as those that are corrupted or temporarily cannot be returned. Defaults to `false`.| -#### Example request +## Example request The following request returns the status of `my-first-snapshot` in the `my-opensearch-repo` repository. Unavailable snapshots are ignored. @@ -54,7 +54,7 @@ GET _snapshot/my-opensearch-repo/my-first-snapshot/_status ```` {% include copy-curl.html %} -#### Example response +## Example response The example that follows corresponds to the request above in the [Example request](#example-request) section. diff --git a/_api-reference/snapshots/get-snapshot.md b/_api-reference/snapshots/get-snapshot.md index da44c1f23d..ac55c0370f 100644 --- a/_api-reference/snapshots/get-snapshot.md +++ b/_api-reference/snapshots/get-snapshot.md @@ -25,7 +25,7 @@ Retrieves information about a snapshot. | verbose | Boolean | Whether to show all, or just basic snapshot information. If `true`, returns all information. If `false`, omits information like start/end times, failures, and shards. Optional, defaults to `true`.| | ignore_unavailable | Boolean | How to handle snapshots that are unavailable (corrupted or otherwise temporarily can't be returned). If `true` and the snapshot is unavailable, the request does not return the snapshot. If `false` and the snapshot is unavailable, the request returns an error. Optional, defaults to `false`.| -#### Example request +## Example request The following request retrieves information for the `my-first-snapshot` located in the `my-opensearch-repo` repository: @@ -34,7 +34,7 @@ GET _snapshot/my-opensearch-repo/my-first-snapshot ```` {% include copy-curl.html %} -#### Example response +## Example response Upon success, the response returns snapshot information: diff --git a/_api-reference/snapshots/restore-snapshot.md b/_api-reference/snapshots/restore-snapshot.md index 7b82f72256..cdb9948c28 100644 --- a/_api-reference/snapshots/restore-snapshot.md +++ b/_api-reference/snapshots/restore-snapshot.md @@ -57,7 +57,7 @@ All request body parameters are optional. * Ingest pipelines * Index lifecycle policies -#### Example request +## Example request The following request restores the `opendistro-reports-definitions` index from `my-first-snapshot`. The `rename_pattern` and `rename_replacement` combination causes the index to be renamed to `opendistro-reports-definitions_restored` because duplicate open index names in a cluster are not allowed. @@ -73,7 +73,7 @@ POST /_snapshot/my-opensearch-repo/my-first-snapshot/_restore } ```` -#### Example response +## Example response Upon success, the response returns the following JSON object: diff --git a/_api-reference/snapshots/verify-snapshot-repository.md b/_api-reference/snapshots/verify-snapshot-repository.md index 12fada3303..e5e6337196 100644 --- a/_api-reference/snapshots/verify-snapshot-repository.md +++ b/_api-reference/snapshots/verify-snapshot-repository.md @@ -32,7 +32,7 @@ Path parameters are optional. | cluster_manager_timeout | Time | Amount of time to wait for a connection to the cluster manager node. Optional, defaults to `30s`. | | timeout | Time | The period of time to wait for a response. If a response is not received before the timeout value, the request fails and returns an error. Defaults to `30s`. | -#### Example request +## Example request The following request verifies that the my-opensearch-repo is functional: @@ -40,7 +40,7 @@ The following request verifies that the my-opensearch-repo is functional: POST /_snapshot/my-opensearch-repo/_verify?timeout=0s&cluster_manager_timeout=50s ```` -#### Example response +## Example response The example that follows corresponds to the request above in the [Example request](#example-request) section. diff --git a/_api-reference/tasks.md b/_api-reference/tasks.md index 5c3a41fd34..e4ca0b6049 100644 --- a/_api-reference/tasks.md +++ b/_api-reference/tasks.md @@ -28,59 +28,6 @@ GET _tasks/ Note that if a task finishes running, it won't be returned as part of your request. For an example of a task that takes a little longer to finish, you can run the [`_reindex`]({{site.url}}{{site.baseurl}}/opensearch/reindex-data) API operation on a larger document, and then run `tasks`. -#### Example response -```json -{ - "nodes": { - "Mgqdm0r9SEGClWxp_RbnaQ": { - "name": "opensearch-node1", - "transport_address": "172.18.0.3:9300", - "host": "172.18.0.3", - "ip": "172.18.0.3:9300", - "roles": [ - "data", - "ingest", - "master", - "remote_cluster_client" - ], - "tasks": { - "Mgqdm0r9SEGClWxp_RbnaQ:17416": { - "node": "Mgqdm0r9SEGClWxp_RbnaQ", - "id": 17416, - "type": "transport", - "action": "cluster:monitor/tasks/lists", - "start_time_in_millis": 1613599752458, - "running_time_in_nanos": 994000, - "cancellable": false, - "headers": {} - } - }, - "Mgqdm0r9SEGClWxp_RbnaQ:17413": { - "node": "Mgqdm0r9SEGClWxp_RbnaQ", - "id": 17413, - "type": "transport", - "action": "indices:data/write/bulk", - "start_time_in_millis": 1613599752286, - "running_time_in_nanos": 172846500, - "cancellable": false, - "parent_task_id": "Mgqdm0r9SEGClWxp_RbnaQ:17366", - "headers": {} - }, - "Mgqdm0r9SEGClWxp_RbnaQ:17366": { - "node": "Mgqdm0r9SEGClWxp_RbnaQ", - "id": 17366, - "type": "transport", - "action": "indices:data/write/reindex", - "start_time_in_millis": 1613599750929, - "running_time_in_nanos": 1529733100, - "cancellable": true, - "headers": {} - } - } - } - } -} -``` You can also use the following parameters with your query. @@ -97,14 +44,29 @@ Parameter | Data type | Description | For example, this request returns tasks currently running on a node named `opensearch-node1`: -#### Example request +## Example requests + +### Return information about running tasks + +The following request returns tasks currently running on a node named `opensearch-node1`: ```json GET /_tasks?nodes=opensearch-node1 ``` {% include copy-curl.html %} -#### Example response +### Return information about active search tasks + +The following request returns detailed information about active search tasks: + +```bash +curl -XGET "localhost:9200/_tasks?actions=*search&detailed +``` +{% include copy.html %} + +## Example response + +The following example response shows information about running tasks: ```json { @@ -148,76 +110,6 @@ GET /_tasks?nodes=opensearch-node1 } ``` -The following request returns detailed information about active search tasks: - -#### Example request - -```bash -curl -XGET "localhost:9200/_tasks?actions=*search&detailed -``` -{% include copy.html %} - -#### Example response - -```json -{ - "nodes" : { - "CRqNwnEeRXOjeTSYYktw-A" : { - "name" : "runTask-0", - "transport_address" : "127.0.0.1:9300", - "host" : "127.0.0.1", - "ip" : "127.0.0.1:9300", - "roles" : [ - "cluster_manager", - "data", - "ingest", - "remote_cluster_client" - ], - "attributes" : { - "testattr" : "test", - "shard_indexing_pressure_enabled" : "true" - }, - "tasks" : { - "CRqNwnEeRXOjeTSYYktw-A:677" : { - "node" : "CRqNwnEeRXOjeTSYYktw-A", - "id" : 677, - "type" : "transport", - "action" : "indices:data/read/search", - "description" : "indices[], search_type[QUERY_THEN_FETCH], source[{\"query\":{\"query_string\":}}]", - "start_time_in_millis" : 1660106254525, - "running_time_in_nanos" : 1354236, - "cancellable" : true, - "cancelled" : false, - "headers" : { }, - "resource_stats" : { - "average" : { - "cpu_time_in_nanos" : 0, - "memory_in_bytes" : 0 - }, - "total" : { - "cpu_time_in_nanos" : 0, - "memory_in_bytes" : 0 - }, - "min" : { - "cpu_time_in_nanos" : 0, - "memory_in_bytes" : 0 - }, - "max" : { - "cpu_time_in_nanos" : 0, - "memory_in_bytes" : 0 - }, - "thread_info" : { - "thread_executions" : 0, - "active_threads" : 0 - } - } - } - } - } - } -} - -``` ### The `resource_stats` object diff --git a/templates/API_TEMPLATE.md b/templates/API_TEMPLATE.md index c4c46fc5ce..02c0f341d9 100644 --- a/templates/API_TEMPLATE.md +++ b/templates/API_TEMPLATE.md @@ -30,13 +30,13 @@ The following table lists the available path parameters. All path parameters are The following table lists the available query parameters. All query parameters are optional. -| Parameter | Data type | Description | +| Parameter | Data type | Description | | :--- | :--- | :--- | | `query_parameter` | String | Example query parameter description. Default is ... | -## Request fields +## Request body fields -The following table lists the available request fields. +The following table lists the available request body fields. | Field | Data type | Description | | :--- | :--- | :--- | @@ -44,7 +44,13 @@ The following table lists the available request fields. | `example_object.required_request_field` | Type | Required request field description. Required. | | `example_object.optional_request_field` | Type | Optional request field description. Optional. Default is ... | -#### Example request +## Example request(s) + +**TIP:** If multiple examples exist for the request, seperate those examples using an `h3` header underneath this section. + +### Request with an example object + +The following example shows an API request with an example object: ```json POST /_example/endpoint/ @@ -57,7 +63,21 @@ POST /_example/endpoint/ ``` {% include copy-curl.html %} -#### Example response +## Request without an example object + +The following example shows an API request without an example object: + +```json +POST /_example/endpoint/ +``` +{% include copy-curl.html %} + + +## Example response + +**TIP:** If multiple response examples exist for the request, seperate those examples using an `h3` header underneath this section, similar to the [Example requests](#example-requests). + +The following example shows an API response:
@@ -76,9 +96,9 @@ POST /_example/endpoint/ ```
-## Response fields +## Response body fields -The following table lists all response fields. +The following table lists all response body fields. | Field | Data type | Description | | :--- | :--- | :--- | @@ -87,3 +107,5 @@ The following table lists all response fields. ## Required permissions If you use the Security plugin, make sure you have the appropriate permissions: `cluster:example/permission/name`. + +