# Query for sum of two nested object fields of a document

**URL:** https://discuss.elastic.co/t/query-for-sum-of-two-nested-object-fields-of-a-document/127750
**Category:** Elasticsearch
**Created:** [April 12, 2018, 7:29am UTC](https://discuss.elastic.co/t/query-for-sum-of-two-nested-object-fields-of-a-document/127750 "2018-04-12T07:29:07Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 12, 2018, 7:42am UTC](https://discuss.elastic.co/t/query-for-sum-of-two-nested-object-fields-of-a-document/127750/2 "2018-04-12T07:42:33Z")

</div>

See the same topic you already opened:

> [@Sum of two fields into a one custom field](https://discuss.elastic.co/t/sum-of-two-fields-into-a-one-custom-field/127600/4):
>
> As long as it's a script it will work with whatever you want. I'm not telling you how to write the script though. Which I don't know as I'm not using painless. I always prefer modifying my data before indexing it.

---

_[View the full topic](https://discuss.elastic.co/t/query-for-sum-of-two-nested-object-fields-of-a-document/127750)._
