Please help me understand the Bool filter

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, deor
    fr for the field locale, the following filter returns results with the
    locale being either en or fr:

{
"filter": {
"bool": {
"must": [
{
"term": {
"tags.komma": "common",
"_cache": false
}
}
],
"must_not": [],
"should": [
{
"term": {
"locale": "en",
"_cache": false
}
}
],
"_cache": false
}
}
}

Here's the result (silly, but functional example data):

{
took: 1
timed_out: false
_shards: {
total: 5
successful: 5
failed: 0
}
hits: {
total: 4
max_score: 1
hits: [
{
_index: fde
_type: booth
_id: NbmePfyGQsKVR5F1gJ1phg
_score: 1
_source: {
idbooth: 40
idorganisation: 3
location: 3C13
name: English booth name
description: English booth desc
locale: en
tags: common
}
}
{
_index: fde
_type: booth
_id: HRBspOmTQ3C1y0jKRfw2FQ
_score: 1
_source: {
idbooth: 40
idorganisation: 3
location: 3C13
name: Nom français
description: Descriptions française
locale: fr
tags: common
}
}
{
_index: fde
_type: booth
_id: Qe6MkFdtQx-7h3YNCBZNDQ
_score: 1
_source: {
idbooth: 38
idorganisation: 3
location: 3C11
tags: booth-tag1, booth-tag-2, common
name: Booth name
description: Booth description
locale: en
}
}
{
_index: fde
_type: booth
_id: ULOdnX6hTxikQe7kHEpFiA
_score: 1
_source: {
idbooth: 41
idorganisation: 3
location: 3C45
tags: sdf, sdfg, common
name: Second
description: I was indexed, but not saved?
locale: en
}
}
]
}

}

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

{

took: 1
timed_out: false
_shards: {
    total: 5
    successful: 5
    failed: 0
}
hits: {
    total: 2
    max_score: 1
    hits: [
        {
            _index: fde
            _type: booth
            _id: JMHUR79zT0SdoCir04EOrg
            _score: 1
            _source: {
                idbooth: 43
                idorganisation: 3
                location: 3C87
                tags: sdf, common
                name: Des isch a Tyroler Universität
                description: Isch des
                locale: de
            }
        }
        {
            _index: fde
            _type: booth
            _id: pcgnocJeRJSIPGpt0W206A
            _score: 1
            _source: {
                idbooth: 42
                idorganisation: 3
                location: 3C99
                tags: sdf, sdfg, common
                name: Neu, nur Deutsch
                description: Lei a deitsche Beschreibung is des
                locale: de
            }
        }
    ]
}

}

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

Best regards,
David

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

On 09/06/13 01:11, David Raison wrote:

  1. 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/:

Well I have now indexed another set of data and now having should {
locale: en } no longer returns "fr" results (nor "de").
Maybe this was simply a hiccup.

Regards,
David

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Did you change refresh settings?
Sounds like a refresh issue...

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 9 juin 2013 à 01:22, David Raison draison@gmail.com a écrit :

On 09/06/13 01:11, David Raison wrote:

  1. 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:

Well I have now indexed another set of data and now having should { locale: en } no longer returns "fr" results (nor "de").
Maybe this was simply a hiccup.

Regards,
David

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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi and sorry for the late reply.

Ah, no, I did not change any refresh settings.
Where and when would one usually do something like that?

I assumed that dropping an entire index and recreating it, including the
setup of analyzers and mapping would sort of reset everything.

Regards,
David

On Sun, Jun 9, 2013 at 3:24 AM, David Pilato david@pilato.fr wrote:

Did you change refresh settings?
Sounds like a refresh issue...

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 9 juin 2013 à 01:22, David Raison draison@gmail.com a écrit :

On 09/06/13 01:11, David Raison wrote:

  1. 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:

Well I have now indexed another set of data and now having should {
locale: en } no longer returns "fr" results (nor "de").
Maybe this was simply a hiccup.

Regards,
David

--
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.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/-GeCVCtE05E/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.