How to include iterative value in message body ctx.results.hits[i>=0]

Hello team, In the message body I want to make the hits result as iterative.
If suppose the alert triggered has 10 hits. The trigger condition met at the 3rd hit result, But in my message body if i want to get that hostname in the particular result I will have to give it as hits.3 but what if the hit is on 4th? Again I need to configure for the remaining individually or is there any iterative thing we can mention in the body so that it checks and throws particular hit.

Ex:
Trigger condition:
[boolean flag = false;

for (int i = 0; i< ctx.results[0].hits.hits.length; i++) {
if ctx.results[0].hits.hits[i]._source.mongodb.replstatus.members.down.count > 0
flag = true;
}
return flag;]
The above one checks for the condition in every hit irrespective of ‘n’ no.of hits.

For suppose the error is on 4th hit result
In my message body I given as:

“Member have reached down state in host:{{ctx.results.0.hits.hits.4._source.mongodb.replstatus.members.down.hosts}} and the count is: {{ctx.results.0.hits.hits.4._source.mongodb.replstatus.members.down.count}}”
Then only it gives the exact result.

If suppose the hit result is on 3rd then trigger condition will work as it is iterative but the message body gives the 4th hit result which gives wrong host name.
So to avoid this, Is there any way we can make the message body also iterative??
ex:
"Member have reached down state in host:{{ctx.results.0.hits.hits.i._source.mongodb.replstatus.members.down.hosts}} and the count is: {{ctx.results.0.hits.hits.i._source.mongodb.replstatus.members.down.count}}???

Please provide any update on this.

Did you find something on this?

Yes I tried my self and got a temporary fix. Hope that works.

[ {{#ctx.results.0.hits.hits}}{{_source.mongodb.replstatus.members.down.hosts}}{{/ctx.results.0.hits.hits}}].

This will the hit relatively irrespective of occurance.

OK, yes this works, thanks!
Did you happen to try how we can aggregate the output by host?
Any thoughts on this would great.