1
0
Эх сурвалжийг харах

[DOCS] Fix stored script example snippet (#83056)

Changes:

* Updates the example Painless script to be valid and aligns it with the example in [How to write a script](https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-using.html#script-stored-scripts).
* Adds a hidden snippets to delete the script for cleanup.

Relates to https://github.com/elastic/elasticsearch/issues/83038
James Rodewig 3 жил өмнө
parent
commit
3845a41804

+ 9 - 4
docs/reference/scripting/apis/create-stored-script-api.asciidoc

@@ -13,14 +13,19 @@ PUT _scripts/my-stored-script
 {
   "script": {
     "lang": "painless",
-    "source": """
-      TimestampHour date =  doc['@timestamp'].value; 
-      return date.getHour()
-    """
+    "source": "Math.log(_score * 2) + params['my_modifier']"
   }
 }
 ----
 
+////
+[source,console]
+----
+DELETE _scripts/my-stored-script
+----
+// TEST[continued]
+////
+
 [[create-stored-script-api-request]]
 ==== {api-request-title}
 

+ 1 - 4
docs/reference/scripting/apis/delete-stored-script-api.asciidoc

@@ -14,10 +14,7 @@ PUT _scripts/my-stored-script
 {
   "script": {
     "lang": "painless",
-    "source": """
-      TimestampHour date =  doc['@timestamp'].value; 
-      return date.getHour()
-    """
+    "source": "Math.log(_score * 2) + params['my_modifier']"
   }
 }
 ----

+ 9 - 4
docs/reference/scripting/apis/get-stored-script-api.asciidoc

@@ -14,10 +14,7 @@ PUT _scripts/my-stored-script
 {
   "script": {
     "lang": "painless",
-    "source": """
-      TimestampHour date =  doc['@timestamp'].value; 
-      return date.getHour()
-    """
+    "source": "Math.log(_score * 2) + params['my_modifier']"
   }
 }
 ----
@@ -29,6 +26,14 @@ GET _scripts/my-stored-script
 ----
 // TEST[continued]
 
+////
+[source,console]
+----
+DELETE _scripts/my-stored-script
+----
+// TEST[continued]
+////
+
 [[get-stored-script-api-request]]
 ==== {api-request-title}