# Query DSL parse elements

**URL:** <https://discuss.elastic.co/t/query-dsl-parse-elements/57845>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [August 11, 2016, 6:33pm UTC](https://discuss.elastic.co/t/query-dsl-parse-elements/57845 "2016-08-11T18:33:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![piyush](https://avatars.discourse-cdn.com/v4/letter/p/ecb155/32.png) [@piyush](https://discuss.elastic.co/u/piyush)\
**Post date:** [August 11, 2016, 6:33pm UTC](https://discuss.elastic.co/t/query-dsl-parse-elements/57845/1 "2016-08-11T18:33:43Z")

</div>

Hi Team,  
I am working on watcher and need some help to retrieve query result set. how can we parse elements from result payloads?

I updated my query and make it time bound but still getting multiple events in the result set, which are in the form of hits elements, PFB. I can read it in "action" section by mentioning 0,1,2,3 elements but how can i make it generic? to send all elements in action body?

input.payload.hits.hits.o.xyz  
input.payload.hits.hits.1.xyz

looking for something like input.payload.hits.hits.X.xyz, where X will be 0,1,2,.. N.

Thanks & Regards

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 23, 2016, 1:53pm UTC](https://discuss.elastic.co/t/query-dsl-parse-elements/57845/2 "2016-08-23T13:53:59Z")

</div>

Hey,

you can use mustache to iterate through a list, see [https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-template.html#\_passing\_an\_array\_of\_strings](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-template.html#_passing_an_array_of_strings)

you can use sth like

```auto
{{#input.payload.hits.hits}}
{{_source.some_field.name_goes.here}}
{{/input.payload.hits.hits}}

```

--Alex

---

<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:** [July 6, 2017, 1:43pm UTC](https://discuss.elastic.co/t/query-dsl-parse-elements/57845/3 "2017-07-06T13:43:27Z")

</div>


