Aggregate children data

I am looking for help/ideas/examples. Thank you in advance for your help.

I have 3 types of docs loaded into elastic search: "parent", "child1", "child2" ("child1", "child2" have "parent" type set as parent in the mapping).
"parent" documents have among other fields "factor1":[some number], "factor2":[some number]. There are about 20,000 documents each with multiple children of both types, with total number or children of each type across all parents 250,000 (500,000 total). Each child document has a field "amount":[some number].

I need to find a value for each parent that is the sum of all "child1" amounts multiplied by "parent" "factor1" divided by sum of all "child2" amounts multiplied by "factor2".

I need to be able to get it for each parent and to be able to search by it: find all parents that have value between 0.4 and 0.8 for example...

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/9ca7c521-7402-41e5-8610-c05444e408f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.