From 75a5a0bbb91297c07bb73540d4341a127220c4de Mon Sep 17 00:00:00 2001 From: Jack Conradson Date: Fri, 20 Dec 2019 10:52:44 -0800 Subject: [PATCH] Document use of context in put stored script (#50446) This documents how to test compile a stored script against a specific context when using PUT/POST. --- docs/reference/scripting/using.asciidoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/reference/scripting/using.asciidoc b/docs/reference/scripting/using.asciidoc index 02a3cc6042c05..9d056415d8f76 100644 --- a/docs/reference/scripting/using.asciidoc +++ b/docs/reference/scripting/using.asciidoc @@ -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]