Scripted nested sum aggregation with root attribute

(István Ignácz) #1


I'm facing the same issue as this one (already closed): Scripted nested sum aggregation with top document field

In an existing index in an elasticsearch 5.6 cluster I have a numeric value and another in a nested document. I'd like to create a scripted sum like this: {"script":"doc['nested.someNumber'] * doc['rootNumber']"}

As far as I know, "include_in_root" property is deprecated since the post was closed and could not find any documentation about this field.

Is the only way to achieve this currently is to create a new field in the nested doc and use "copy_to" in the root doc?


(Ryan Ernst) #2

Yes, if you want to access a value in a script for each nested doc, you will need that value in the nested doc directly.