MUHAMMAD SAMIULLAH 84e4ab158e
[DOC] Format all API pages according to the API template (#5169)
* Fix APIs File

Signed-off-by: samipak458 <samipak458@gmail.com>

* Update API files according to API template

Signed-off-by: samipak458 <samipak458@gmail.com>

* Update exec-stored-script.md

Signed-off-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com>

* Update cat-aliases.md

Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com>

* Update cat-allocation.md

Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com>

* Update cat-cluster_manager.md

Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com>

* Update cat-count.md

Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com>

* Update cat-field-data.md

Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com>

* Update cat-health.md

Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com>

* updated

* updated

* updated

---------

Signed-off-by: samipak458 <samipak458@gmail.com>
Signed-off-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com>
Signed-off-by: MUHAMMAD SAMIULLAH <samipak458@gmail.com>
Co-authored-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com>
2023-10-23 09:53:52 -05:00

71 lines
1.6 KiB
Markdown

---
layout: default
title: Get Stored Script
parent: Script APIs
nav_order: 3
---
# Get stored script
**Introduced 1.0**
{: .label .label-purple }
Retrieves a stored script.
## Path parameters
| Parameter | Data type | Description |
:--- | :--- | :---
| script | String | Stored script or search template name. Required.|
## Query parameters
| Parameter | Data type | Description |
:--- | :--- | :---
| cluster_manager_timeout | Time | Amount of time to wait for a connection to the cluster manager. Optional, defaults to `30s`. |
#### Example request
The following retrieves the `my-first-script` stored script.
````json
GET _scripts/my-first-script
````
{% include copy-curl.html %}
#### Example response
The `GET _scripts/my-first-script` request returns the following fields:
````json
{
"_id" : "my-first-script",
"found" : true,
"script" : {
"lang" : "painless",
"source" : """
int total = 0;
for (int i = 0; i < doc['ratings'].length; ++i) {
total += doc['ratings'][i];
}
return total;
"""
}
}
````
## Response fields
The `GET _scripts/my-first-script` request returns the following response fields:
| Field | Data type | Description |
:--- | :--- | :---
| _id | String | The script's name. |
| found | Boolean | The requested script exists and was retrieved. |
| script | Object | The script definition. See [Script object](#script-object). |
#### Script object
| Field | Data type | Description |
:--- | :--- | :---
| lang | String | The script's language. |
| source | String | The script's body. |