Skip to content

Commit

Permalink
Document use of context in put stored script (#50446)
Browse files Browse the repository at this point in the history
This documents how to test compile a stored script against a specific 
context when using PUT/POST.
  • Loading branch information
jdconrad authored Dec 20, 2019
1 parent 3ccc9ec commit 75a5a0b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/reference/scripting/using.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,22 @@ POST _scripts/calculate-score
-----------------------------------
// TEST[setup:twitter]

You may also specify a context as part of the url path to compile a
stored script against that specific context in the form of
`/_scripts/{id}/{context}`:

[source,console]
-----------------------------------
POST _scripts/calculate-score/score
{
"script": {
"lang": "painless",
"source": "Math.log(_score * 2) + params.my_modifier"
}
}
-----------------------------------
// TEST[setup:twitter]

This same script can be retrieved with:

[source,console]
Expand Down

0 comments on commit 75a5a0b

Please sign in to comment.