Home > OS >  Elasticsearch count aggregation number of buckets
Elasticsearch count aggregation number of buckets

Time:01-28

Given this elasticsearch query which mimics that sql request "select count(distinct(keyword))as nb from table"

{"aggs":{"nb":{"terms":{"field":"keyword","size":99999999}}}}

Is there any faster way of getting that total number of distinct keywords in my elastic ?

CodePudding user response:

Yes, you should use the cardinality aggregation, which is exactly what you want (unique count of terms).

  •  Tags:  
  • Related