按基数过滤
我正在运行此嵌套聚合以获取与候选人相关联的所有组 -
"aggs" : { "remove_empty":{ "filter": { "not": { "term": {"candidate_id":"NA"}} }, "aggs": { "distinct_ids":{ "terms":{ "field":"candidate_id"}, "aggs":{ "distinct_groups":{ "terms":{ "field":"candidate_group" }}}} } } }
返回预期结果 -
"aggregations":{
"remove_empty":{
"doc_count":160322,
"distinct_ids":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[
{
"key":"1401",
"distinct_groups":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[
{
"key":"group4",
"doc_count":619
}
]
}
},
{
"key":"1402",
"distinct_groups":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[
{
"key":"group1",
"doc_count":619
},
{
"key":"group6",
"doc_count":619
}
]
}
},
{
"key":"1403",
"distinct_groups":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[
{
"key":"group3",
"doc_count":619
}
]
}
},
{
"key":"1404",
"distinct_groups":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[
{
"key":"group6",
"doc_count":619
}
]
}
}
]
}
}
}
但是,我只需要与两个或更多组相关联的candidate_id -
{
"key":"1402",
"distinct_groups":{
"doc_count_error_upper_bound":0,
"sum_other_doc_count":0,
"buckets":[
{
"key":"group1",
"doc_count":619
},
{
"key":"group6",
"doc_count":619
}
]
}
}
有没有办法按基数过滤>这个查询中有1个?