# Only first key of the bucket is resulted. In actions, how to return all the results?

**URL:** https://discuss.elastic.co/t/only-first-key-of-the-bucket-is-resulted-in-actions-how-to-return-all-the-results/165449
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [January 23, 2019, 4:04pm UTC](https://discuss.elastic.co/t/only-first-key-of-the-bucket-is-resulted-in-actions-how-to-return-all-the-results/165449 "2019-01-23T16:04:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![shiv94](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@shiv94](https://discuss.elastic.co/u/shiv94)
#### Post date: [January 23, 2019, 4:04pm UTC](https://discuss.elastic.co/t/only-first-key-of-the-bucket-is-resulted-in-actions-how-to-return-all-the-results/165449/1 "2019-01-23T16:04:37Z")

</div>

Hello ,

I would like get all the results in the bucket. for example,  
`{{ctx.payload.aggregations.host.buckets.0.key}}` returns only first key in the bucket, if we want other keys I can use `{{ctx.payload.aggregations.host.buckets.1.key}}` but If I have many how can I get all the results.

```
{{ctx.payload.aggregations.host.buckets.0.key}}
{{ctx.payload.aggregations.host.buckets.1.key}}
{{ctx.payload.aggregations.host.buckets.2.key}}
....
{{ctx.payload.aggregations.host.buckets.n.key}}

```

My idea is to use variable called ' i ' through loop condition `{{ctx.payload.aggregations.host.buckets.i.key}}`? one more option is is to use streams but can we use in actions? how to get displayed with streams?

can anyone help me with this ? Can we use loops in actions? Do we have anyother options

---

<div class="post-metadata">

### Author: ![shiv94](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@shiv94](https://discuss.elastic.co/u/shiv94)
#### Post date: [January 24, 2019, 3:03pm UTC](https://discuss.elastic.co/t/only-first-key-of-the-bucket-is-resulted-in-actions-how-to-return-all-the-results/165449/2 "2019-01-24T15:03:01Z")

</div>

Can anyone help me with this?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 21, 2019, 3:03pm UTC](https://discuss.elastic.co/t/only-first-key-of-the-bucket-is-resulted-in-actions-how-to-return-all-the-results/165449/3 "2019-02-21T15:03:06Z")

</div>

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