# Groovy script to append integer value for partial update

**URL:** <https://discuss.elastic.co/t/groovy-script-to-append-integer-value-for-partial-update/24980>\
**Category:** Elasticsearch\
**Created:** [July 6, 2015, 7:30pm UTC](https://discuss.elastic.co/t/groovy-script-to-append-integer-value-for-partial-update/24980 "2015-07-06T19:30:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hanish\_Bansal](https://avatars.discourse-cdn.com/v4/letter/h/e36b37/32.png) [@Hanish\_Bansal](https://discuss.elastic.co/u/Hanish_Bansal)\
**Post date:** [July 6, 2015, 7:30pm UTC](https://discuss.elastic.co/t/groovy-script-to-append-integer-value-for-partial-update/24980/1 "2015-07-06T19:30:20Z")

</div>

Hi All,

I am using groovy script to do partial updates in ElasticSearch.

I have an integer field. I want to append value to that field on each  
update request.

For example: "id" field has value 114561604. On each update request i want  
to append other id to that field as integer array like [114561604,114561605].

I am using below script:

{  
"script" : "ctx.\_source.id+=new\_tag ",  
"params" : {  
"new\_tag" : 114561605  
}  
}

For string field this script is working fine but for integer it is not  
working as expected.

Getting below error:

failed to parse [id]]; nested: NumberFormatException  
[For input string: "114561604114561605"

Please let me know how each further value can be appended as integer using  
groovy script.

---

<div class="post-metadata">

**Author:** ![Hanish\_Bansal](https://avatars.discourse-cdn.com/v4/letter/h/e36b37/32.png) [@Hanish\_Bansal](https://discuss.elastic.co/u/Hanish_Bansal)\
**Post date:** [July 7, 2015, 4:49pm UTC](https://discuss.elastic.co/t/groovy-script-to-append-integer-value-for-partial-update/24980/2 "2015-07-07T16:49:26Z")

</div>

It would be great help if anyone can suggest for same.

---

<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:** [July 6, 2017, 12:03am UTC](https://discuss.elastic.co/t/groovy-script-to-append-integer-value-for-partial-update/24980/3 "2017-07-06T00:03:07Z")

</div>


