I am trying to migrate my watcher to the latest elastic search Xpack
Here is my condition script
"condition": {
"script": {
"inline": "def sf = new SimpleDateFormat('yyyy-MM-dd');ctx.vars.from = sf.parse(new Date());if (ctx.payload.aggregations.minutes20.buckets.size() == 0) return false;def latest = ctx.payload.aggregations.minutes20.buckets[-1]; return latest.occurences.buckets.any{it.doc_count > 0};",
"lang": "painless"
}
},
i am having issues compiling the watcher. below are the error details
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... st.occurences.buckets.Any{it.doc_count > 0};",
" ^---- HERE"
],
"script": "def sf = new SimpleDateFormat('yyyy-MM-dd');ctx.vars.from = sf.parse(new Date());if (ctx.payload.aggregations.minutes20.buckets.size() == 0) return false;def latest = ctx.payload.aggregations.minutes20.buckets[-1]; return latest.occurences.buckets.Any{it.doc_count > 0};",
"lang": "painless"
}
],
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... st.occurences.buckets.Any{it.doc_count > 0};",
" ^---- HERE"
],
"script": "def sf = new SimpleDateFormat('yyyy-MM-dd');ctx.vars.from = sf.parse(new Date());if (ctx.payload.aggregations.minutes20.buckets.size() == 0) return false;def latest = ctx.payload.aggregations.minutes20.buckets[-1]; return latest.occurences.buckets.Any{it.doc_count > 0};",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "unexpected token ['{'] was expecting one of [{, ';'}]."
}
},
"status": 500
}