Skip to content

Commit bba2b30

Browse files
Added a full request in creating a script API (#10293) (#10300)
1 parent 2708bfd commit bba2b30

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

_api-reference/script-apis/create-stored-script.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,24 @@ All parameters are optional.
4545
| Field | Data type | Description |
4646
:--- | :--- | :---
4747
| lang | String | Scripting language. Required. |
48-
| source | String or Object | Required. <br /> <br /> For scripts, a string with the contents of the script. <br /> <br /> 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. |
48+
| source | String or Object | Required. <br /> <br /> For scripts, a string with the contents of the script. <br /> <br /> 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. |
4949

5050
## Example request
5151

5252
The following example requests uses an index called `books` with the following documents:
5353

54-
````json
55-
{"index":{"_id":1}}
54+
```json
55+
POST _bulk
56+
{"index":{"_index":"books","_id":1}}
5657
{"name":"book1","author":"Faustine","ratings":[4,3,5]}
57-
{"index":{"_id":2}}
58+
{"index":{"_index":"books","_id":2}}
5859
{"name":"book2","author":"Amit","ratings":[5,5,5]}
59-
{"index":{"_id":3}}
60+
{"index":{"_index":"books","_id":3}}
6061
{"name":"book3","author":"Gilroy","ratings":[2,1,5]}
61-
````
62+
```
63+
{% include copy-curl.html %}
6264

63-
### Creating a painless script
65+
### Creating a Painless script
6466

6567
The following request creates the Painless script `my-first-script`. It sums the ratings for each book and displays the sum in the output.
6668

@@ -81,7 +83,7 @@ PUT _scripts/my-first-script
8183
````
8284
{% include copy.html %}
8385

84-
The example above uses the syntax of the Dev Tools console in OpenSearch Dashboards. You can also use a curl request.
86+
The preceding example uses the syntax of the Dev Tools console in OpenSearch Dashboards. You can also use a curl request.
8587
{: .note }
8688

8789
The following curl request is equivalent to the previous Dashboards console example:

0 commit comments

Comments
 (0)