# Watcher multiple conditions for nested buckets

**URL:** <https://discuss.elastic.co/t/watcher-multiple-conditions-for-nested-buckets/138152>\
**Category:** Elasticsearch\
**Created:** [July 2, 2018, 8:41am UTC](https://discuss.elastic.co/t/watcher-multiple-conditions-for-nested-buckets/138152 "2018-07-02T08:41:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kskubala](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@kskubala](https://discuss.elastic.co/u/kskubala)\
**Post date:** [July 2, 2018, 8:41am UTC](https://discuss.elastic.co/t/watcher-multiple-conditions-for-nested-buckets/138152/1 "2018-07-02T08:41:00Z")

</div>

Hi !  
I have many buckets and nested up to two buckets inside each of them. I want to iterate thru all of the buckets and check whether each of bucket's value is greater (for each bucket threshold is different).  
It means I need two "OR" conditions. I have tried "array\_compare" :{ "array\_compare" : {} } but it looks like it is not allowed.

> ```
> "aggregations": {
> "last_day": {
> "doc_count": 4431,
> "time": {
> "buckets": [
> {
> "key_as_string": "2018-07-01T08:29:00.000Z",
> "doc_count": 3,
> "component": {
> "doc_count_error_upper_bound": 0,
> "sum_other_doc_count": 0,
> "buckets": [
> {
> "doc_count": 3,
> "key": "ui"
> }
> ]
> },
> "key": 1530433740000
> },
> {
> "key_as_string": "2018-07-01T08:30:00.000Z",
> "doc_count": 3,
> "component": {
> "doc_count_error_upper_bound": 0,
> "sum_other_doc_count": 0,
> "buckets": [
> {
> "doc_count": 3,
> "key": "ui"
> }
> ]
> },
> "key": 1530433800000
> },
> 
> ```

Want to set one condition for 'ui' and another for 'service'.

---

<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:** [July 3, 2018, 8:16am UTC](https://discuss.elastic.co/t/watcher-multiple-conditions-for-nested-buckets/138152/2 "2018-07-03T08:16:56Z")

</div>

If you want to to compare more than one field, you need to use a painless script and the `script` condition.

--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 31, 2018, 8:16am UTC](https://discuss.elastic.co/t/watcher-multiple-conditions-for-nested-buckets/138152/3 "2018-07-31T08:16:58Z")

</div>

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