# Sum of a field in a parent node and grouping by a field in a child node

**URL:** <https://discuss.elastic.co/t/sum-of-a-field-in-a-parent-node-and-grouping-by-a-field-in-a-child-node/324948>\
**Category:** Elasticsearch\
**Created:** [February 8, 2023, 1:43am UTC](https://discuss.elastic.co/t/sum-of-a-field-in-a-parent-node-and-grouping-by-a-field-in-a-child-node/324948 "2023-02-08T01:43:22Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![learningelastic](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@learningelastic](https://discuss.elastic.co/u/learningelastic)\
**Post date:** [February 8, 2023, 1:46pm UTC](https://discuss.elastic.co/t/sum-of-a-field-in-a-parent-node-and-grouping-by-a-field-in-a-child-node/324948/5 "2023-02-08T13:46:55Z")

</div>

Your answer worked! And I have a related question on this page here in case you know the answer. Thank you in advance!

> [@These two nested aggregations produce the same result, but is one approach better than the other?](https://discuss.elastic.co/t/these-two-nested-aggregations-produce-the-same-result-but-is-one-approach-better-than-the-other/324941):
>
> I have two scenarios that produce identical aggregation results in the final GET order/\_search query. The only difference between the two scenarios is where I choose to declare the type: nested in the mapping and what I specify in the nested.path: in the query. SCENARIO 1 - Declare nested for order\_items PUT order POST order/\_mapping { "properties": { "order\_items": { "type": "nested", "properties": { "product\_id": { "type": "long" }, "pro…

---

_[View the full topic](https://discuss.elastic.co/t/sum-of-a-field-in-a-parent-node-and-grouping-by-a-field-in-a-child-node/324948)._
