I have 2 level of nesting in my mapping: business -> funds -> admins/market
I want count of
f_id's
that matches with particular admin_name
ES MAPPING
{
"text_index" : {
"mappings" : {
"properties" : {
"buisness_id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
},
"buisness_type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"funds" : {
"type" : "nested",
"properties" : {
"f_id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
"admins" : {
"type" : "nested",
"properties" : {
"admin_name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
},
"admin_id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
"market" : {
"type" : "nested",
"properties" : {
"mkt_name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"mkt_id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
}
}
}
aggs count query:
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "funds",
"query": {
"nested": {
"path": "funds.admins",
"query": {
"bool": {
"must": [
{
"match": {
"funds.admins.admin_name": "NOMAD"
}
}
]
}
}
}
}
}
}
]
}
},
"aggs": {
"funds_count": {
"nested": {
"path": "funds"
},
"aggs": {
"f_count": {
"value_count": {
"field": "funds.f_id.keyword"
}
}
}
}
}
}
But the aggs count query is giving the incorrect results