# How to search by an specific value or where field does not exists in Elasticsearch with and condition

**URL:** <https://discuss.elastic.co/t/how-to-search-by-an-specific-value-or-where-field-does-not-exists-in-elasticsearch-with-and-condition/217962>\
**Category:** Elasticsearch\
**Created:** [February 5, 2020, 10:35am UTC](https://discuss.elastic.co/t/how-to-search-by-an-specific-value-or-where-field-does-not-exists-in-elasticsearch-with-and-condition/217962 "2020-02-05T10:35:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkishore](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkishore/32/58054_2.png) [@dkishore](https://discuss.elastic.co/u/dkishore)\
**Post date:** [February 5, 2020, 10:35am UTC](https://discuss.elastic.co/t/how-to-search-by-an-specific-value-or-where-field-does-not-exists-in-elasticsearch-with-and-condition/217962/1 "2020-02-05T10:35:10Z")

</div>

How to search by a specific value or where the field does not exist in Elasticsearch with and condition  
below is the query I'm trying  
{  
"query":{  
"bool":{  
"should":[  
{  
"query\_string":{  
"query":"( isStart:false) AND (isStop:false)"  
}  
},  
{  
"exists":{  
"field":"isStart"  
}  
},  
{  
"exists":{  
"field":"isStop"  
}  
}  
]  
}  
}  
}

I want to query (( **isStart: false** or exists field **isStart** ) AND ( **isStop: false** or exists field **isStop** ))

how can I get this done

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 5, 2020, 12:58pm UTC](https://discuss.elastic.co/t/how-to-search-by-an-specific-value-or-where-field-does-not-exists-in-elasticsearch-with-and-condition/217962/2 "2020-02-05T12:58:51Z")

</div>

You probably need something like:

```
bool
  must [
    { bool -> should [isStart: false or exists field isStart] },
    { bool -> should [isStop: false or exists field isStop] }
  ]
```

---

<div class="post-metadata">

**Author:** ![dkishore](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkishore/32/58054_2.png) [@dkishore](https://discuss.elastic.co/u/dkishore)\
**Post date:** [February 5, 2020, 4:17pm UTC](https://discuss.elastic.co/t/how-to-search-by-an-specific-value-or-where-field-does-not-exists-in-elasticsearch-with-and-condition/217962/3 "2020-02-05T16:17:01Z")

</div>

@dadoonet, Thanks

---

<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:** [March 4, 2020, 4:17pm UTC](https://discuss.elastic.co/t/how-to-search-by-an-specific-value-or-where-field-does-not-exists-in-elasticsearch-with-and-condition/217962/4 "2020-03-04T16:17:03Z")

</div>

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