# Bool query problem

**URL:** <https://discuss.elastic.co/t/bool-query-problem/14539>\
**Category:** Elasticsearch\
**Created:** [November 22, 2013, 9:21am UTC](https://discuss.elastic.co/t/bool-query-problem/14539 "2013-11-22T09:21:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slava\_G](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@Slava\_G](https://discuss.elastic.co/u/Slava_G)\
**Post date:** [November 22, 2013, 9:21am UTC](https://discuss.elastic.co/t/bool-query-problem/14539/1 "2013-11-22T09:21:26Z")

</div>

Hi,  
Trying to execute query :  
{  
"bool" : {  
"must" : [ {  
"match" : {  
"\_all" : {  
"query" : "Any text that don't exists",  
"type" : "phrase"  
}  
}  
}, {  
"term" : {  
"account" : "slava.test@gmail.com"  
}  
}, {  
"term" : {  
"source" : "gmail"  
}  
} ]  
}  
}

But always get a result, even the text in the match query does not exists  
in any indexed document.

What I do wrong ?

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [November 22, 2013, 9:28am UTC](https://discuss.elastic.co/t/bool-query-problem/14539/2 "2013-11-22T09:28:30Z")

</div>

Could you gist a full curl recreation?  
Hard to tell without all details.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 22 novembre 2013 at 10:21:29, slavag ([slavago@gmail.com](mailto:slavago@gmail.com)) a écrit:

Hi,  
Trying to execute query :  
{  
"bool" : {  
"must" : [ {  
"match" : {  
"\_all" : {  
"query" : "Any text that don't exists",  
"type" : "phrase"  
}  
}  
}, {  
"term" : {  
"account" : "slava.test@gmail.com"  
}  
}, {  
"term" : {  
"source" : "gmail"  
}  
} ]  
}  
}

But always get a result, even the text in the match query does not exists in any indexed document.

What I do wrong ?

## Thanks

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Slava\_G](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@Slava\_G](https://discuss.elastic.co/u/Slava_G)\
**Post date:** [November 22, 2013, 11:43am UTC](https://discuss.elastic.co/t/bool-query-problem/14539/3 "2013-11-22T11:43:25Z")

</div>

Hi David,  
Actually this is from the java code (the query build  
with BoolQueryBuilder). When I execute it by curl :  
url -XGET 'localhost:9200/6e5bde01-94c2-44c8-a339-ee8ece640e39/\_search/' -d  
'{  
"query" : {  
"bool" : {  
"must" : [ {  
"match" : {  
"\_all" : {  
"query" : "muku",  
"type" : "phrase"  
}  
}  
}, {  
"term" : {  
"account" : "[slava.test@gmail.com](mailto:slava.test@gmail.com)"  
}  
}, {  
"term" : {  
"source" : "gmail"  
}  
} ]  
}  
}  
}  
}'

It's working fine - no result returned. But when it's via java code it's  
returned many results. Please note that all inside "query" is taken from  
the query object in Java.

Thanks

On Friday, November 22, 2013 11:28:30 AM UTC+2, David Pilato wrote:

> Could you gist a full curl recreation?  
> Hard to tell without all details.
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet[https://www.google.com/url?q=https%3A%2F%2Ftwitter.com%2Fdadoonet&sa=D&sntz=1&usg=AFQjCNE-DMC3YEu3X\_lhRIhUzuSZGsaSqA](https://www.google.com/url?q=https%3A%2F%2Ftwitter.com%2Fdadoonet&sa=D&sntz=1&usg=AFQjCNE-DMC3YEu3X_lhRIhUzuSZGsaSqA)  
> | @elasticsearchfr[https://www.google.com/url?q=https%3A%2F%2Ftwitter.com%2Felasticsearchfr&sa=D&sntz=1&usg=AFQjCNGfXdQ98RWFMJXdiqpKnZb5GMg0zA](https://www.google.com/url?q=https%3A%2F%2Ftwitter.com%2Felasticsearchfr&sa=D&sntz=1&usg=AFQjCNGfXdQ98RWFMJXdiqpKnZb5GMg0zA)
> 
> Le 22 novembre 2013 at 10:21:29, slavag ([sla...@gmail.com](mailto:sla...@gmail.com) \<javascript:\>)  
> a écrit:
> 
> Hi,  
> Trying to execute query :  
> {  
> "bool" : {  
> "must" : [ {  
> "match" : {  
> "\_all" : {  
> "query" : "Any text that don't exists",  
> "type" : "phrase"  
> }  
> }  
> }, {  
> "term" : {  
> "account" : "[slava...@gmail.com](mailto:slava...@gmail.com) \<javascript:\>"  
> }  
> }, {  
> "term" : {  
> "source" : "gmail"  
> }  
> } ]  
> }  
> }
> 
> But always get a result, even the text in the match query does not exists  
> in any indexed document.
> 
> What I do wrong ?
> 
> ## Thanks
> 
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [November 22, 2013, 1:23pm UTC](https://discuss.elastic.co/t/bool-query-problem/14539/4 "2013-11-22T13:23:58Z")

</div>

I meant a full curl recreation:

Delete index, Create Index, put mapping, put some docs, refresh, query…

See: [http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/)

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 22 novembre 2013 at 12:43:28, slavag ([slavago@gmail.com](mailto:slavago@gmail.com)) a écrit:

Hi David,  
Actually this is from the java code (the query build with BoolQueryBuilder). When I execute it by curl :  
url -XGET 'localhost:9200/6e5bde01-94c2-44c8-a339-ee8ece640e39/\_search/' -d '{  
"query" : {  
"bool" : {  
"must" : [ {  
"match" : {  
"\_all" : {  
"query" : "muku",  
"type" : "phrase"  
}  
}  
}, {  
"term" : {  
"account" : "slava.test@gmail.com"  
}  
}, {  
"term" : {  
"source" : "gmail"  
}  
} ]  
}  
}  
}  
}'

It's working fine - no result returned. But when it's via java code it's returned many results. Please note that all inside "query" is taken from the query object in Java.

Thanks

On Friday, November 22, 2013 11:28:30 AM UTC+2, David Pilato wrote:  
Could you gist a full curl recreation?  
Hard to tell without all details.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 22 novembre 2013 at 10:21:29, slavag ([sla...@gmail.com](mailto:sla...@gmail.com)) a écrit:

Hi,  
Trying to execute query :  
{  
"bool" : {  
"must" : [ {  
"match" : {  
"\_all" : {  
"query" : "Any text that don't exists",  
"type" : "phrase"  
}  
}  
}, {  
"term" : {  
"account" : "slava...@gmail.com"  
}  
}, {  
"term" : {  
"source" : "gmail"  
}  
} ]  
}  
}

But always get a result, even the text in the match query does not exists in any indexed document.

What I do wrong ?

## Thanks

## You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com). For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:05am UTC](https://discuss.elastic.co/t/bool-query-problem/14539/5 "2017-07-06T02:05:20Z")

</div>


