# Terms Aggregation

Terms Aggregation is a bucket aggregation that allows you to group documents into buckets based on the values of a specific field.&#x20;

**Example -**

{% code lineNumbers="true" %}

```json
{
   "query": {
            "bool": {
                "must": {
                    "term": {"product_type_name": "Dress"}
                }
            }
        },
        "aggs": {
            "unique_products": {
                "terms": {
                    "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 be stored under buckets, according to the possible value of the field "<mark style="color:purple;">prod\_name</mark>".
