# Reporting back search results via email

**URL:** <https://discuss.elastic.co/t/reporting-back-search-results-via-email/98258>\
**Category:** Elasticsearch\
**Created:** [August 24, 2017, 3:29pm UTC](https://discuss.elastic.co/t/reporting-back-search-results-via-email/98258 "2017-08-24T15:29:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![X\_Calibur](https://avatars.discourse-cdn.com/v4/letter/x/b2d939/32.png) [@X\_Calibur](https://discuss.elastic.co/u/X_Calibur)\
**Post date:** [August 24, 2017, 3:29pm UTC](https://discuss.elastic.co/t/reporting-back-search-results-via-email/98258/1 "2017-08-24T15:29:35Z")

</div>

Hi,

Is it possible to configure a Watcher to attach the search query results to the email once it's fired?

Thanks

---

<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 25, 2017, 7:47am UTC](https://discuss.elastic.co/t/reporting-back-search-results-via-email/98258/2 "2017-08-25T07:47:40Z")

</div>

Hey,

yes, you can just iterate through the search hits in the `body` of an email action. Results would be available in `ctx.payload.hits.hits` if you only have one search input.

You might want to check out [this blog post](https://www.elastic.co/blog/watching-the-watches-writing-debugging-and-testing-watches) how to efficiently write and debug watches, it should shorten your testing cycles -I know it's pretty long, but worth it (spoiler: I wrote it, I might be biased 🙂

--Alex

---

<div class="post-metadata">

**Author:** ![X\_Calibur](https://avatars.discourse-cdn.com/v4/letter/x/b2d939/32.png) [@X\_Calibur](https://discuss.elastic.co/u/X_Calibur)\
**Post date:** [August 29, 2017, 8:50am UTC](https://discuss.elastic.co/t/reporting-back-search-results-via-email/98258/3 "2017-08-29T08:50:36Z")

</div>

Hi Alex,

thanks for the reply.  
Is there a more specific example for iterating through the search hits?  
I got kind of lost in your blog post...

Thanks  
X

---

<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:** [September 26, 2017, 8:51am UTC](https://discuss.elastic.co/t/reporting-back-search-results-via-email/98258/4 "2017-09-26T08:51:18Z")

</div>

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