# Combine exists query

**URL:** <https://discuss.elastic.co/t/combine-exists-query/97685>\
**Category:** Elasticsearch\
**Created:** [August 20, 2017, 12:35pm UTC](https://discuss.elastic.co/t/combine-exists-query/97685 "2017-08-20T12:35:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuval](https://avatars.discourse-cdn.com/v4/letter/y/977dab/32.png) [@Yuval](https://discuss.elastic.co/u/Yuval)\
**Post date:** [August 20, 2017, 12:35pm UTC](https://discuss.elastic.co/t/combine-exists-query/97685/1 "2017-08-20T12:35:12Z")

</div>

Hey,  
I want to look for documents who has field x **OR** field y.  
I can't use bool:should because i'm using a bool:filter in the same query..

my current query:

> GET /testing/\_search?size=200  
> {  
> "query": {  
> "bool": {  
> "filter":[  
> {"regexp": {  
> "look\_for\_regex.keyword": "some\_regex" }},  
> {"exists":{"field":"x"}}  
> ]  
> }  
> }  
> }

the current query only looks for field x, how should i filter the documents who has field x or y?

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [August 20, 2017, 7:12pm UTC](https://discuss.elastic.co/t/combine-exists-query/97685/2 "2017-08-20T19:12:36Z")

</div>

Hi,

You can have bool queries into another bool must or should, etc...  
So you can have a big bool with 2 should, with minumum should match = 1.  
1rst bool will contains your current bool query, the 2d should will contain the exist on the y field.

---

<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 17, 2017, 7:12pm UTC](https://discuss.elastic.co/t/combine-exists-query/97685/3 "2017-09-17T19:12:36Z")

</div>

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