I have a terms aggregation with an IncludeExclude filter:
{
"size": 0,
"query": {
...
},
"aggregations": {
"facets": {
"terms": {
"field": "type_id",
"size": 20,
"order": [
{
"_count": "desc"
},
{
"_key": "asc"
}
],
"include": "PARENT$.*",
"exclude": ".+__\\*"
}
}
}
This will return me the top 20 facets for field type_id
. I also want to know the total number of unique terms for this facet, so I want to add another aggregate:
"total": {
"cardinality": {
"field": "type_id"
}
}
but I can't filter this total by include/exclude, so the count doesn't match with the terms aggregate above. Is there an efficient way to achieve this?