# How to apply condition on the aggregation bucket group\_doc hits

**URL:** https://discuss.elastic.co/t/how-to-apply-condition-on-the-aggregation-bucket-group-doc-hits/196866
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [August 27, 2019, 3:30am UTC](https://discuss.elastic.co/t/how-to-apply-condition-on-the-aggregation-bucket-group-doc-hits/196866 "2019-08-27T03:30:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![saurabh06](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saurabh06/32/51529_2.png) [@saurabh06](https://discuss.elastic.co/u/saurabh06)
#### Post date: [August 27, 2019, 3:30am UTC](https://discuss.elastic.co/t/how-to-apply-condition-on-the-aggregation-bucket-group-doc-hits/196866/1 "2019-08-27T03:30:26Z")

</div>

Is their any way to apply condition on the aggregation bucket group\_doc hits in watcher Elastic search?

---

<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 28, 2019, 11:20am UTC](https://discuss.elastic.co/t/how-to-apply-condition-on-the-aggregation-bucket-group-doc-hits/196866/2 "2019-08-28T11:20:53Z")

</div>

Yes, you need to use a [script condition](https://www.elastic.co/guide/en/elastic-stack-overview/7.3/condition-script.html) though and write a small painless script. See the [examples repo](https://github.com/elastic/examples/tree/master/Alerting/Sample%20Watches) for a few examples

---

<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 25, 2019, 11:20am UTC](https://discuss.elastic.co/t/how-to-apply-condition-on-the-aggregation-bucket-group-doc-hits/196866/3 "2019-09-25T11:20:59Z")

</div>

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