Reputation: 420
GET /test*/_search
{
"size": 0,
"query": {
"match_all": {}
},
"aggs": {
"test": {
"terms": {
"field": "name.keyword",
"min_doc_count": 10
}
}
}
}
the above query will return all the unique names which occurs more than 10 times. I want the query to return the count of those unique names with occurrance more than 10 times.
I could not find a way to do find out the count. Can anybody help with it.
Thanks.
Upvotes: 2
Views: 4415
Reputation: 1251
This will do the trick.
"count" will give you the count of unique names with occurrences more than 10 times.
GET /test*/_search?filter_path=aggregations.count
{
"size": 0,
"query": {
"match_all": {}
},
"aggs": {
"test": {
"terms": {
"field": "name.keyword",
"min_doc_count": 10
},
"aggs": {
"test2": {
"value_count": {
"field": "name.keyword"
}
},
"test3":{
"bucket_script": {
"buckets_path": "test2",
"script": "return 1"
}
}
}
},
"count":{
"sum_bucket": {
"buckets_path": "test>test3"
}
}
}
}
Let me know if this solves your problem.
Upvotes: 1