How to dynamically aggregate the fields of a document?

I have an Elasticsearch instance where I store products with the following schema:

    "productId": "37807",
    "name": "trendy t-shirt",
    "price": "72.59",
    "customFilters": {
      "color": "red",
      "size": "large",
    }

Depending on the category of the product, there might be different customFilters. E.g. if it is a mobile phone, then we may have "screen size", "ram" etc.

    "productId": "37808",
    "name": "mobile phone",
    "price": "100.59",
    "customFilters": {
      "screen_size": "5",
      "ram": "3",
    }

What I need, is to retrieve all the aggregations for the "customFilters" without explicitly specifying the name of the filters. So in the first case I need to get the aggregation for "color" and "size" whereas in the second one for "screen_size" and "ram".

Any ideas? Thnx

you can use a template aggregation!