# 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 -**

{% code lineNumbers="true" %}

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

{% endcode %}

In the above example, the aggregation will be performed over the field "<mark style="color:purple;">unique\_products</mark>" over all documents that pass the query.  The aggregation results will return the number of all possible value of the field "<mark style="color:purple;">prod\_name</mark>".
