mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
[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
This commit is contained in:
parent
b552d5cb0e
commit
3845a41804
3 changed files with 19 additions and 12 deletions
|
@ -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}
|
||||
|
||||
|
|
|
@ -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']"
|
||||
}
|
||||
}
|
||||
----
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue