# How would I build a OR query for field exists

**URL:** <https://discuss.elastic.co/t/how-would-i-build-a-or-query-for-field-exists/258065>\
**Category:** Elasticsearch\
**Created:** [December 9, 2020, 3:12am UTC](https://discuss.elastic.co/t/how-would-i-build-a-or-query-for-field-exists/258065 "2020-12-09T03:12:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_Gibbs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m_gibbs/32/45665_2.png) [@M\_Gibbs](https://discuss.elastic.co/u/M_Gibbs)\
**Post date:** [December 9, 2020, 3:12am UTC](https://discuss.elastic.co/t/how-would-i-build-a-or-query-for-field-exists/258065/1 "2020-12-09T03:12:42Z")

</div>

Hey all,

I've managed to create a query that searches for two fields, but both must exist. I'd like to build a query that requires field1 OR field2 to exist.

Any pointers? I can't find anything in the docs related to this.

Thanks!

---

<div class="post-metadata">

**Author:** ![seanziee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seanziee/32/45151_2.png) [@seanziee](https://discuss.elastic.co/u/seanziee)\
**Post date:** [December 10, 2020, 12:18am UTC](https://discuss.elastic.co/t/how-would-i-build-a-or-query-for-field-exists/258065/2 "2020-12-10T00:18:57Z")

</div>

Under `bool`, use `should` instead of `must`. That is the equivalent to an `OR`

See [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

---

<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:** [January 7, 2021, 12:19am UTC](https://discuss.elastic.co/t/how-would-i-build-a-or-query-for-field-exists/258065/3 "2021-01-07T00:19:10Z")

</div>

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