Cardinality Aggregation

Cardinality Aggregation allows you to estimate the number of unique values of fields in a collection, which is often referred to as the count of distinct or unique values.

Example -

   "query": {
       "bool": {
            "must": {
                "term": {"product_type_name": "Dress"}
    "aggs": {
        "unique_products": {
            "cardinality": {
                "field": "prod_name"

In the above example, the aggregation will be performed over the field "unique_products" over all documents that pass the query. The aggregation results will return the number of all possible value of the field "prod_name".

Last updated