Hi,
My Monitor condition is below.
Monitor- Extraction Query
{
"size": 1,
"sort":{"Date":"desc"},
"query": {
"bool": {
"adjust_pure_negative": true,
"boost": 1
}
}
}
Output-
{
"_shards": {
"total": 4,
"failed": 0,
"successful": 4,
"skipped": 0
},
"hits": {
"hits": [
{
"_index": "titan_cal_spread",
"_source": {
"symbol": "TITAN",
"std_dev": 3.7,
"upper_range": 11.1,
"current_month_close": 1921.6,
"mean": 7.4,
"weekday": "Thursday",
"difference": 12.050000000000182,
"Date": "2022-06-30T00:00:00",
"next_month_close": 1933.65,
"lower_range": 3.7
},
"_id": "A4okuIEB0-WmbmBjPwd4",
"sort": [
1656547200000
],
"_score": null
}
],
"total": {
"value": 204,
"relation": "eq"
},
"max_score": null
},
"took": 32,
"timed_out": false
}
I want to create Trigger condition based on fields present inside hits.hits._source
to make trigger work on dynamic values present in fields.
Trigger-
return ctx.results[0].hits.hits.params['_source']['difference'] < ctx.results[0].hits.hits.params['_source']['lower_range']
Error-
{
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"return ctx.results[0].hits.hits.params['_source']['difference'] < ctx.results[0].hits.hits.params['_source']['lower_range']",
" ^---- HERE"
],
"script" : "return ctx.results[0].hits.hits.params['_source']['difference'] < ctx.results[0].hits.hits.params['_source']['lower_range']",
"lang" : "painless",
"position" : {
"offset" : 31,
"start" : 0,
"end" : 123
},
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Illegal list shortcut value [params]."
}
}