# Query (a AND b) OR c does not return c

**URL:** <https://discuss.elastic.co/t/query-a-and-b-or-c-does-not-return-c/2948>\
**Category:** Elasticsearch\
**Created:** [May 14, 2010, 2:37am UTC](https://discuss.elastic.co/t/query-a-and-b-or-c-does-not-return-c/2948 "2010-05-14T02:37:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![colinsurprenant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colinsurprenant/32/14776_2.png) [@colinsurprenant](https://discuss.elastic.co/u/colinsurprenant)\
**Post date:** [May 14, 2010, 2:37am UTC](https://discuss.elastic.co/t/query-a-and-b-or-c-does-not-return-c/2948/1 "2010-05-14T02:37:51Z")

</div>

Hi,

It seem queries of the type (a AND b) OR c do not find the results  
from c, it only find results for (a AND b).

I am using ES 0.6.0 with default configuration.

Here's how to reproduce:

create 2 documents:

curl -XPUT '[http://localhost:9200/test1/test1/1](http://localhost:9200/test1/test1/1)' -d '  
{  
"text" : "the quick brow fox aaaaaa bbbbbb"  
}  
'

curl -XPUT '[http://localhost:9200/test1/test1/2](http://localhost:9200/test1/test1/2)' -d '  
{  
"text" : "the quick brow fox cccccc"  
}  
'  
run the search:

curl -XGET '[http://localhost:9200/test1/test1/\_search?q=(aaaaaa%20AND%20bbbbbb)%20OR%20cccccc](http://localhost:9200/test1/test1/_search?q=(aaaaaa%20AND%20bbbbbb)%20OR%20cccccc)'

result:

{"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"hits":[{"\_index":"test1","\_type":"test1","\_id":"1",  
"\_source" :  
{  
"text" : "the quick brow fox aaaaaa bbbbbb"  
}

the document with cccccc should have been found.

Is there something I am missing?

Thanks,  
Colin

---

<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:** [May 14, 2010, 5:17am UTC](https://discuss.elastic.co/t/query-a-and-b-or-c-does-not-return-c/2948/2 "2010-05-14T05:17:19Z")

</div>

Hi,

Its a bug in elasticseach, I have committed a fix and will be part of 0.7.  
Thanks for working on an example!, and thanks for #danielg from IRC.

cheers,  
shay.banon

On Fri, May 14, 2010 at 5:37 AM, Colin Surprenant \<  
[colin.surprenant@gmail.com](mailto:colin.surprenant@gmail.com)\> wrote:

> Hi,
> 
> It seem queries of the type (a AND b) OR c do not find the results  
> from c, it only find results for (a AND b).
> 
> I am using ES 0.6.0 with default configuration.
> 
> Here's how to reproduce:
> 
> create 2 documents:
> 
> curl -XPUT '[http://localhost:9200/test1/test1/1](http://localhost:9200/test1/test1/1)' -d '  
> {  
> "text" : "the quick brow fox aaaaaa bbbbbb"  
> }  
> '
> 
> curl -XPUT '[http://localhost:9200/test1/test1/2](http://localhost:9200/test1/test1/2)' -d '  
> {  
> "text" : "the quick brow fox cccccc"  
> }  
> '  
> run the search:
> 
> curl -XGET '  
> [http://localhost:9200/test1/test1/\_search?q=(aaaaaa%20AND%20bbbbbb)%20OR%20cccccc](http://localhost:9200/test1/test1/_search?q=(aaaaaa%20AND%20bbbbbb)%20OR%20cccccc)  
> '
> 
> result:
> 
> {"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"hits":[{"\_index":"test1","\_type":"test1","\_id":"1",  
> "\_source" :  
> {  
> "text" : "the quick brow fox aaaaaa bbbbbb"  
> }
> 
> the document with cccccc should have been found.
> 
> Is there something I am missing?
> 
> Thanks,  
> Colin

---

<div class="post-metadata">

**Author:** ![colinsurprenant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colinsurprenant/32/14776_2.png) [@colinsurprenant](https://discuss.elastic.co/u/colinsurprenant)\
**Post date:** [May 14, 2010, 3:04pm UTC](https://discuss.elastic.co/t/query-a-and-b-or-c-does-not-return-c/2948/3 "2010-05-14T15:04:38Z")

</div>

Good stuff. Just built master and I confirm the fix works. Thanks!

Colin

On Fri, May 14, 2010 at 1:17 AM, Shay Banon  
[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> Hi,  
> Its a bug in elasticseach, I have committed a fix and will be part of 0.7.  
> Thanks for working on an example!, and thanks for #danielg from IRC.  
> cheers,  
> shay.banon
> 
> On Fri, May 14, 2010 at 5:37 AM, Colin Surprenant  
> [colin.surprenant@gmail.com](mailto:colin.surprenant@gmail.com) wrote:
> 
> > Hi,
> > 
> > It seem queries of the type (a AND b) OR c do not find the results  
> > from c, it only find results for (a AND b).
> > 
> > I am using ES 0.6.0 with default configuration.
> > 
> > Here's how to reproduce:
> > 
> > create 2 documents:
> > 
> > curl -XPUT '[http://localhost:9200/test1/test1/1](http://localhost:9200/test1/test1/1)' -d '  
> > {  
> > "text" : "the quick brow fox aaaaaa bbbbbb"  
> > }  
> > '
> > 
> > curl -XPUT '[http://localhost:9200/test1/test1/2](http://localhost:9200/test1/test1/2)' -d '  
> > {  
> > "text" : "the quick brow fox cccccc"  
> > }  
> > '  
> > run the search:
> > 
> > curl -XGET  
> > '[http://localhost:9200/test1/test1/\_search?q=(aaaaaa%20AND%20bbbbbb)%20OR%20cccccc](http://localhost:9200/test1/test1/_search?q=(aaaaaa%20AND%20bbbbbb)%20OR%20cccccc)'
> > 
> > result:
> > 
> > {"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"hits":[{"\_index":"test1","\_type":"test1","\_id":"1",  
> > "\_source" :  
> > {  
> > "text" : "the quick brow fox aaaaaa bbbbbb"  
> > }
> > 
> > the document with cccccc should have been found.
> > 
> > Is there something I am missing?
> > 
> > Thanks,  
> > Colin

---

<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, 4:24am UTC](https://discuss.elastic.co/t/query-a-and-b-or-c-does-not-return-c/2948/4 "2017-07-06T04:24:08Z")

</div>


