Filter nested field only in aggregation

My index has a nested field, looking like this:

              "services": {
                  "type": "nested",
                  "properties": {
                        "type": {
                            "type": "keyword"
                        },
                        "quantity": {
                            "type": "keyword"
                        },
                       "alias": {
                            "type": "keyword"
                        },

I want to have the sum of all quantity of the services group by type and alias expect for type with value as abc for instance.

Here is a part of the aggregation, but it has parsing_exception:

            "aggregations": {
            "nested": {
                "nested": {
                    "path": "services",
                    "query": {
                    "bool": {
                        "must_not": [
                            {
                                "term": {
                                    "services.type": "abc"
                                }
                            }
                        ]
                    }
                }
                },
                
                "aggregations": {
                    "company_group": {
                        "terms": {
                            "field": "services.alias",
                            "size": 1000
                        },
                        "aggregations": {
                            "res_type": {
                                "terms": {
                                    "field": "services.type",
                                    "size": 10
                                },
                                "aggregations": {
                                    "daily_overage": {
                                        "sum": {
                                            "field": "services.quantity"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },

Is there any way to filter only the nested field service above?

is it solved ?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.