# Please help me understand the Bool query

**URL:** <https://discuss.elastic.co/t/please-help-me-understand-the-bool-query/12330>\
**Category:** Elasticsearch\
**Created:** [June 8, 2013, 7:11pm UTC](https://discuss.elastic.co/t/please-help-me-understand-the-bool-query/12330 "2013-06-08T19:11:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwisarts](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kwisarts/32/2004_2.png) [@kwisarts](https://discuss.elastic.co/u/kwisarts)\
**Post date:** [June 8, 2013, 7:11pm UTC](https://discuss.elastic.co/t/please-help-me-understand-the-bool-query/12330/1 "2013-06-08T19:11:39Z")

</div>

These are essentially two questions:

1. How does the _should_ part of a Bool filter influence the results  
returned?  
Could one say that where _must_ creates an AND combination of filters,  
should creates an OR?

2. I have used the Bool filter in something that I now realize, makes little  
sense. However, also don't understand its behavior:  
Given I have documents in my index which can have either value of /en/, /de/  
or /fr/ for the field _locale_, the following filter returns results with  
the locale being either /en/ or /fr/:

Here's the result (example data):

The same result is being returned if I set _locale_ to be /fr/.

If I use /de/ for the locale _field_ in should, I get

/Question is:/ Why does the filter with should -\> locale -\> en/fr even show  
results where the should condition isn't met?

Best regards,  
David

--  
View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Please-help-me-understand-the-Bool-query-tp4036264.html](http://elasticsearch-users.115913.n3.nabble.com/Please-help-me-understand-the-Bool-query-tp4036264.html)  
Sent from the ElasticSearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
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:** [June 15, 2013, 2:28pm UTC](https://discuss.elastic.co/t/please-help-me-understand-the-bool-query/12330/2 "2013-06-15T14:28:29Z")

</div>

1. Basically, should helps to increase scoring. So if two documents match the same must clause and one of them only match the should clause, this last document will be more relevant and will get an higher score.

If you have a must query and some should clauses, should clauses does not have to match unless you set minimum\_number\_should\_match \> 0.  
If you don't have any must or must\_not clause, then at least one of the should clauses must be satisfied.

1. I don't fully follow you here. Could you illustrate and gist a full curl recreation?

Does it help?

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

Le 8 juin 2013 à 21:11, kwisarts [draison@gmail.com](mailto:draison@gmail.com) a écrit :

> These are essentially two questions:
> 
> 1. How does the _should_ part of a Bool filter influence the results  
> returned?  
> Could one say that where _must_ creates an AND combination of filters,  
> should creates an OR?
> 
> 2. I have used the Bool filter in something that I now realize, makes little  
> sense. However, also don't understand its behavior:  
> Given I have documents in my index which can have either value of /en/, /de/  
> or /fr/ for the field _locale_, the following filter returns results with  
> the locale being either /en/ or /fr/:
> 
> Here's the result (example data):
> 
> The same result is being returned if I set _locale_ to be /fr/.
> 
> If I use /de/ for the locale _field_ in should, I get
> 
> /Question is:/ Why does the filter with should -\> locale -\> en/fr even show  
> results where the should condition isn't met?
> 
> Best regards,  
> David
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Please-help-me-understand-the-Bool-query-tp4036264.html](http://elasticsearch-users.115913.n3.nabble.com/Please-help-me-understand-the-Bool-query-tp4036264.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> 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:31am UTC](https://discuss.elastic.co/t/please-help-me-understand-the-bool-query/12330/3 "2017-07-06T02:31:03Z")

</div>


