Elasticsearch array value count aggregation
As you say the attribute field is nested. Try this, this will work
{ "size": 0, "aggs": { "count": { "nested": { "path": "attributes" }, "aggs": { "attribCount": { "terms": { "field": "attributes.name" } }, "attribVal": { "terms": { "field": "attributes.name" }, "aggs": { "attribval2": { "terms": { "field": "attributes.value" } } } } } } }}