Aria Marble 21386b05d0
script api documentation (#1094)
* Add script documentation.

Signed-off-by: Steve Murphy <stevemurphy@BCSR-11413.local>

* Use my own example script insteady of Elastic's.

Signed-off-by: Steve Murphy <stevemurphy@BCSR-11413.local>

* edditing and format changes. verified API requests and scripts. various corrections

Signed-off-by: ariamarble <armarble@amazon.com>

* made a couple of suggested changes

Signed-off-by: ariamarble <armarble@amazon.com>

* made further corrections

Signed-off-by: ariamarble <armarble@amazon.com>

Signed-off-by: Steve Murphy <stevemurphy@BCSR-11413.local>
Signed-off-by: ariamarble <armarble@amazon.com>
Co-authored-by: Steve Murphy <stevemurphy@BCSR-11413.local>
2022-09-02 15:09:13 -07:00

1.5 KiB

layout title parent grand_parent nav_order
default Get Stored Script Script APIs REST API reference 3

Get stored script

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.

Sample request

The following retrieves the my-first-script stored script.

GET _scripts/my-first-script

Sample response

The GET _scripts/my-first-script request returns the following fields:

{
  "_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

Field Data Type Description
lang String The script's language.
source String The script's body.