mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 07:37:19 -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": {
|
"script": {
|
||||||
"lang": "painless",
|
"lang": "painless",
|
||||||
"source": """
|
"source": "Math.log(_score * 2) + params['my_modifier']"
|
||||||
TimestampHour date = doc['@timestamp'].value;
|
|
||||||
return date.getHour()
|
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
|
////
|
||||||
|
[source,console]
|
||||||
|
----
|
||||||
|
DELETE _scripts/my-stored-script
|
||||||
|
----
|
||||||
|
// TEST[continued]
|
||||||
|
////
|
||||||
|
|
||||||
[[create-stored-script-api-request]]
|
[[create-stored-script-api-request]]
|
||||||
==== {api-request-title}
|
==== {api-request-title}
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,7 @@ PUT _scripts/my-stored-script
|
||||||
{
|
{
|
||||||
"script": {
|
"script": {
|
||||||
"lang": "painless",
|
"lang": "painless",
|
||||||
"source": """
|
"source": "Math.log(_score * 2) + params['my_modifier']"
|
||||||
TimestampHour date = doc['@timestamp'].value;
|
|
||||||
return date.getHour()
|
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
|
@ -14,10 +14,7 @@ PUT _scripts/my-stored-script
|
||||||
{
|
{
|
||||||
"script": {
|
"script": {
|
||||||
"lang": "painless",
|
"lang": "painless",
|
||||||
"source": """
|
"source": "Math.log(_score * 2) + params['my_modifier']"
|
||||||
TimestampHour date = doc['@timestamp'].value;
|
|
||||||
return date.getHour()
|
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
@ -29,6 +26,14 @@ GET _scripts/my-stored-script
|
||||||
----
|
----
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
|
|
||||||
|
////
|
||||||
|
[source,console]
|
||||||
|
----
|
||||||
|
DELETE _scripts/my-stored-script
|
||||||
|
----
|
||||||
|
// TEST[continued]
|
||||||
|
////
|
||||||
|
|
||||||
[[get-stored-script-api-request]]
|
[[get-stored-script-api-request]]
|
||||||
==== {api-request-title}
|
==== {api-request-title}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue