# Create a query based on given input

**URL:** <https://discuss.elastic.co/t/create-a-query-based-on-given-input/154662>\
**Category:** Elasticsearch\
**Created:** [October 30, 2018, 12:54pm UTC](https://discuss.elastic.co/t/create-a-query-based-on-given-input/154662 "2018-10-30T12:54:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Euan](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@Euan](https://discuss.elastic.co/u/Euan)\
**Post date:** [October 30, 2018, 12:54pm UTC](https://discuss.elastic.co/t/create-a-query-based-on-given-input/154662/1 "2018-10-30T12:54:10Z")

</div>

Hey all

I am rather new to Elasticsearch, only been using is for the last 3 days on and off. I was wondering is there a way that I can create a search query, based on the input given?

I have 2 input fields, _phrase_ and _status_, with 3 possible combinations for them

1. Phrase and status are given
2. A phrase and no status is given
3. No phrase and a status given.

Is there any way that I can create a single query to handle this rather than have 3 separate queries for each scenario?

Regards

---

<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:** [October 30, 2018, 1:20pm UTC](https://discuss.elastic.co/t/create-a-query-based-on-given-input/154662/2 "2018-10-30T13:20:18Z")

</div>

Use a bool query with 3 should clauses inside and that should answer to your needs.

---

<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:** [November 27, 2018, 1:20pm UTC](https://discuss.elastic.co/t/create-a-query-based-on-given-input/154662/3 "2018-11-27T13:20:20Z")

</div>

Closed on November 27, 2018, 1:20pm UTC

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