# Arithmetic operation during update/upsert

**URL:** https://discuss.elastic.co/t/arithmetic-operation-during-update-upsert/71025
**Category:** Elasticsearch
**Created:** [January 10, 2017, 6:07am UTC](https://discuss.elastic.co/t/arithmetic-operation-during-update-upsert/71025 "2017-01-10T06:07:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Yasho](https://avatars.discourse-cdn.com/v4/letter/y/c2a13f/32.png) [@Yasho](https://discuss.elastic.co/u/Yasho)
#### Post date: [January 10, 2017, 6:07am UTC](https://discuss.elastic.co/t/arithmetic-operation-during-update-upsert/71025/1 "2017-01-10T06:07:40Z")

</div>

Hi,

I have a scenario where in I want to update a document however while I am updating i want to also do an arithmetic (sum) operation on the existing field value, for example - if a existing field x = 10 then while update the new x = 5 then i need my document to add these two as x = 10+5 = 15.

Please let me know if this is possible.

Thanks,

Yasho

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 10, 2017, 6:43am UTC](https://discuss.elastic.co/t/arithmetic-operation-during-update-upsert/71025/2 "2017-01-10T06:43:23Z")

</div>

this should be possible through [scripted updates](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/docs-update.html#_scripted_updates).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 7, 2017, 6:43am UTC](https://discuss.elastic.co/t/arithmetic-operation-during-update-upsert/71025/3 "2017-02-07T06:43:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
