Groovy script to append integer value for partial update


(Hanish Bansal) #1

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.


(Hanish Bansal) #2

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


(system) #3