# Nested condition in watcher

**URL:** <https://discuss.elastic.co/t/nested-condition-in-watcher/147365>\
**Category:** Elasticsearch\
**Created:** [September 5, 2018, 9:59am UTC](https://discuss.elastic.co/t/nested-condition-in-watcher/147365 "2018-09-05T09:59:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmk](https://avatars.discourse-cdn.com/v4/letter/k/a9adbd/32.png) [@kmk](https://discuss.elastic.co/u/kmk)\
**Post date:** [September 5, 2018, 9:59am UTC](https://discuss.elastic.co/t/nested-condition-in-watcher/147365/1 "2018-09-05T09:59:40Z")

</div>

Hi All, my requirement is check the nested watcher conditions.  
if ( message = "File received" )  
if ( message = "file not loaded" )  
then send alert for not loading  
else send alert for not receiving

We already implemented inner if else by using payload hits.  
query: {  
bool: {  
must: [  
{match\_phrase: {message: file loaded }}  
]  
}  
},  
condition: {  
compare: {  
ctx.payload.hits.total: {  
lt: 1  
}  
}  
},  
actions: {  
-- SEND MAIL --  
}

Please help me how to achieve the multiple conditions.

---

<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:** [October 3, 2018, 9:59am UTC](https://discuss.elastic.co/t/nested-condition-in-watcher/147365/2 "2018-10-03T09:59:41Z")

</div>

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