Scripted nested sum aggregation with top document field

Hi everybody,

I have a document that has two double fields one on the top level document and the other one into a nested object.I need to do a sum aggregation based on the script sum:{"script":"doc['nested.doubleValue'] * doc['otherDoubleValue']"}.

I tried by doing a nested aggregation over the nested object and than back up with a reverse nested aggregation but it looks like I can't pass the value of the nested double property up to the reverse or viceversa.

Is there a standard way to do scripting using nested and root properties?

Thanks a lot
Matteo

I think to do this you will need to add "include_in_root": true to the mapping for the child document field so that it is available on the parent document. see https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-nested-type.html#_mapping for more details

That's exactly what I need: thanks a lot!