Learning some elasticsearch here and I'm a bit stumped on using min and max functions in scripted field definitions. First,
GET my_index/_search
{
"query" : {
"match_all": {}
},
"script_fields" : {
"test1" : {
"script" : {
"lang": "painless",
"source": "min(doc[\"this field\"],5)"
}
}
}
}
And I am rewarded with
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"min(doc[\"end\"],5)",
"^---- HERE"
],
"script": "min(doc[\"end\"],5)",
"lang": "painless"
}
], ...
I thought maybe I needed to namespace it with Long.min
and got back
"reason": "runtime error",
"script_stack": [
"""Long.min(doc["end"],5)""",
" ^---- HERE"
],
This appears to be progress, but why would the problem be doc
?
They appear to be in the painless API reference and I think it would be a little idiotic if they were not available. I keep searching for combinations of "painless min max function" but all I get is what I've linked above and a soup of unrelated things.
What am I doing wrong here?