Watcher Iteration questions

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}}" } ] } }

Hey,

this is currently not supported - you cannot loop through a result set and fire an action for each of the elements in the set. We are currently considering to add this as a feature though.

A current workaround currently could be to send the whole data over to logstash and deal with this over there.

--Alex

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.