# Conjunction of queries

**URL:** <https://discuss.elastic.co/t/conjunction-of-queries/7242>\
**Category:** Elasticsearch\
**Created:** [April 5, 2012, 3:00pm UTC](https://discuss.elastic.co/t/conjunction-of-queries/7242 "2012-04-05T15:00:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![android](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@android](https://discuss.elastic.co/u/android)\
**Post date:** [April 5, 2012, 3:00pm UTC](https://discuss.elastic.co/t/conjunction-of-queries/7242/1 "2012-04-05T15:00:57Z")

</div>

Hey guys,

I have a query in the form : ((field1:a OR field2:i\*) AND (f5:x OR f6:y OR)) OR test:y

I know I can do this with query string, but if the value to query has 'or' or 'and' as it's prefix, it returns all possible values for that field. Is there any other way for me to write this other than query\_string

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 8, 2012, 5:58pm UTC](https://discuss.elastic.co/t/conjunction-of-queries/7242/2 "2012-04-08T17:58:59Z")

</div>

Youc an build the query yoursearch using a combination of bool queries and  
text queries on the relevant fields.

On Thu, Apr 5, 2012 at 6:00 PM, android [orcunsimsek@gmail.com](mailto:orcunsimsek@gmail.com) wrote:

> Hey guys,
> 
> I have a query in the form : ((field1:a OR field2:i\*) AND (f5:x OR f6:y  
> OR))  
> OR test:y
> 
> I know I can do this with query string, but if the value to query has 'or'  
> or 'and' as it's prefix, it returns all possible values for that field. Is  
> there any other way for me to write this other than query\_string
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/conjunction-of-queries-tp3887473p3887473.html](http://elasticsearch-users.115913.n3.nabble.com/conjunction-of-queries-tp3887473p3887473.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:** [July 6, 2017, 3:33am UTC](https://discuss.elastic.co/t/conjunction-of-queries/7242/3 "2017-07-06T03:33:15Z")

</div>


