I'm using the bool query for the 'must' and 'must_not' feature. It works as expected until I get to a property that is 3 levels deep. for example a simple match query such as ...
GET city/town/_search
{
"query": {
"match": {
"contact.residence.address": "Rocky Road"
}
}
}
works just fine and returns the results but if I do the same in a bool query like ..
GET city/town/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"contact.residence.address": "Rocky Road"
}
}
]
}
}
}
return NO Results. Why is this????? Keep in mind other bool queries such as ..
GET city/town/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"store.name": "Hendersons"
}
}
]
}
}
}
work just fine! Its only for any field that is 3 level deep, hence searching any term that is prop1.prop3.prop3
contact.residence.addressfield mapped withtexttype. If it is the case then by replacingtermwithmatchin your second query will work as expected. I would suggest you to read the section Why doesn’t the term query match my document? in official docs here.