Use doc field value in nested aggregation

My index has the following partly mapping:

"properties" : {
          "price" : {
            "type" : "double"
          },
          "services" : {
                   "type" : "nested",
                   "properties" : {
                       "quantity" : {
                            "type" : "double"
                        }
                   }
          },...

I am struggling to calculate sum of all quantity inside services and then multiple with price using painless script.
When I use nested aggregation to the path services, the doc['price'] is always 0.0.
If I use reverse nested then I could not access the values of quantity.

Is there any way to achieve this using painless script?

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