These are essentially two questions:
-
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? -
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.