Browse Source

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.
Jack Conradson 5 years ago
parent
commit
75a5a0bbb9
1 changed files with 16 additions and 0 deletions
  1. 16 0
      docs/reference/scripting/using.asciidoc

+ 16 - 0
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]