I have an elasticsearch query that to me seems to be ignoring the "must_not" part (using sense to test/debug)
POST /myserver.dev/indexedproduct/_search
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"isPublished": true
}
},
{
"term": {
"isProjectPublished": true
}
},
{
"term": {
"hidden": false
}
},
{
"bool": {
"must_not": [
{
"term": {
"excludedMarkets": ["GI"]
}
}
]
}
},
{
"bool": {
"should": [
{
"terms": {
"category": [
"headwear"
]
}
}
]
}
}
]
}
}
}
}
}
This is returning 104 results.
If I run:
POST /myserver.dev/indexedproduct/_search
{
"query": {
"bool": {
"must_not": { "match": { "excludedMarkets": "GI"}}
}
}
}
Then this returns 41 results.
I'd expect the first (not working one) to return 41 or less results due to the "must_not" clause.
I have looked at the ES documentation and my query looks correctly formed in terms of filtered queries and nested must/must_not statements.
Any help would be appreciated.
EDIT, test data, just 2 , one with the GI exludedMarkerts, and one without, meaning the end result should return just one,
"_index":"myindex.dev",
"_type":"indexedproduct",
"_id":"29426",
"_score":1,
"_source":{
"id":29426,
"sku":"0123",
"description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ne.",
"searchKeywords":[
"Lorem",
"ipsum",
"dolor"
],
"productType":[
"Ipsum"
],
"category":[
"Lorem"
],
"colour":[
"Black/Black"
],
"prices":{
"eur":35,
"gbp":28
},
"catalogId":3,
"ageRange":[
"adults"
],
"brand":[
null
],
"available":true,
"bestSeller":false,
"collections":[
"lorumipsum"
],
"fit":[
"fitted"
],
"newArrival":false,
"style":[
"Lorum"
],
"excludedMarkets":[
"BA",
"GI",
"MC",
"MD",
"SM",
"AL"
],
"isPublished":true,
"isTranslated":false,
"isProjectPublished":true,
"hidden":false,
"availableDate":"2015-09-17T01:00:00+01:00"
}
},
"_index":"myindex.dev",
"_type":"indexedproduct",
"_id":"2942",
"_score":1,
"_source":{
"id":2942,
"sku":"012",
"description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ne.",
"searchKeywords":[
"Lorem",
"ipsum",
"dolor"
],
"productType":[
"IpsumLorem"
],
"category":[
"IpsumLorem"
],
"colour":[
"Black/Blue"
],
"prices":{
"eur":35,
"gbp":28
},
"catalogId":3,
"ageRange":[
"adults"
],
"brand":[
null
],
"available":true,
"bestSeller":false,
"collections":[
"lorumipsum"
],
"fit":[
"fitted"
],
"newArrival":false,
"style":[
"Lorum"
],
"excludedMarkets":[
"BA",
"MC",
"MD",
"SM",
"AL"
],
"isPublished":true,
"isTranslated":false,
"isProjectPublished":true,
"hidden":false,
"availableDate":"2015-09-17T01:00:00+01:00"
}
}