Aggregation on specific object in an array

This one worked :smiley:

{
    "size": 0,
    "aggs": {
        "agg_custom_field": {
            "nested": {
                "path": "custom_fields"
            },
            "aggs": {
                "root_filter": {
                    "filter": {
                        "bool": {
                            "filter": [
                                {
                                    "match": {
                                        "custom_fields.label": "Application Module"
                                    }
                                }
                            ]
                        }
                    },
                    "aggs": {
                        "agg_value": {
                            "terms": {
                                "field": "custom_fields.value"
                            }
                        }
                    }
                }
            }
        }
    }
}
1 Like