Come across the the link - Querying a multiple level nested object. That basically helps solve my problem.
Instead of separated paths on different nested object query,
{
"query": {
"bool": {
"must": [
{ ... nested query on path1 }
{ ... nested query on path2 }
]
}
}
}
query should be specified with base path then down to the deeper level. So each level can specify its own condition.
"query": {
"nested": {
"path": "level1tag.level2tag.level3tag",
"query": {
"bool": {
"must": [
{
"term": { "level1tag.level2tag.level3tag.level3_attr1": "value A" }
},
{
"nested": {
"path": "level1tag.level2tag.level3tag.level4tag",
"query": {
"bool": {
"must" : [
{ "term": { "level1tag.level2tag.level3tag.level4tag.level4_attr1" : "value B"} }
]
}
}
}
}
]
}
}
}
}