I wanted to know if there is a way to iterate over the ctx.payload.hits array to get ctx.payload.hits.0._source to go to ctx.payload.hits.1._source such that I can use 1 watcher to post inidividual slack messages for each hit.
Here is what I have -- I'm fairly new to this... so please let me know of any improvements you notice.
{ "trigger": { "schedule": { "interval": "15m" } }, "input": { "search": { "request": { "search_type": "query_then_fetch", "indices": [ "remedyforce-*" ], "types": [], "body": { "size": 100, "query": { "bool": { "must": [ { "match": { "isRush": "true" } }, { "match": { "_type": "ir_or_sr" } } ], "filter": [ { "range": { "createdDate": { "gte": "now-6h" } } } ] } } } } } }, "condition": { "script": { "inline": "ctx.payload.hits.total > 0", "lang": "painless" } }, "actions": { "notify-slack": { "slack": { "message": { "from": "Rush Notifier", "to": [ "#trialauthcodechannel" ], "attachments": [ { "title": "Rush Request", "text": " {{#ctx.payload.hits.hits.0._source}}Rush Request was entered. Please check Remedyforce SR {{number}}\n{{/ctx.payload.hits.hits.0._source}}" } ] } }