我具有以下要求:
拉特说我的aggregation
在场上-branchOfficeLocations.regTypeDRPCounts.drpType
而我的filter
在场上-branchOfficeLocations.branchAddress.countryCode
我需要将过滤器放在聚合部分的某处,但似乎无法获得正确的查询。该过滤器位于第二级字段上,与第二级上的聚合字段不同。
任何帮助将不胜感激!
下面是我的查询:
{
"from": 0,
"size": 0,
"query": {
"bool": {
"must": [
{
"nested": {
"query": {
"bool": {
"must": [
{
"nested": {
"query": {
"term": {
"branchOfficeLocations.branchAddress.countryCode.keyword": {
"value": "usa",
"boost": 1.0
}
}
},
"path": "branchOfficeLocations.branchAddress",
"ignore_unmapped": false,
"score_mode": "none",
"boost": 1.0
}
}
],
"adjust_pure_negative": true,
"boost": 1.0
}
},
"path": "branchOfficeLocations",
"ignore_unmapped": false,
"score_mode": "none",
"boost": 1.0
}
}
],
"adjust_pure_negative": true,
"boost": 1.0
}
},
"aggregations": {
"branchOfficeLocations.regTypeDRPCounts.drpType": {
"nested": {
"path": "branchOfficeLocations.regTypeDRPCounts"
},
"aggregations": {
"branchOfficeLocations.regTypeDRPCounts.drpType": {
"terms": {
"field": "branchOfficeLocations.regTypeDRPCounts.drpType.keyword",
"size": 100,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": true,
"order": [
{
"_count": "desc"
},
{
"_key": "asc"
}
]
},
"aggregations": {
"parent_count": {
"reverse_nested": {}
}
}
}
}
},
"branchOfficeLocations.regTypeDRPCounts.drpType_missing": {
"nested": {
"path": "branchOfficeLocations.regTypeDRPCounts"
},
"aggregations": {
"branchOfficeLocations.regTypeDRPCounts.drpType": {
"missing": {
"field": "branchOfficeLocations.regTypeDRPCounts.drpType.keyword"
},
"aggregations": {
"parent_count": {
"reverse_nested": {}
}
}
}
}
}
}