# Update value of a field

**URL:** <https://discuss.elastic.co/t/update-value-of-a-field/61363>\
**Category:** Elasticsearch\
**Created:** [September 23, 2016, 10:24am UTC](https://discuss.elastic.co/t/update-value-of-a-field/61363 "2016-09-23T10:24:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhirish](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@Dhirish](https://discuss.elastic.co/u/Dhirish)\
**Post date:** [September 23, 2016, 10:24am UTC](https://discuss.elastic.co/t/update-value-of-a-field/61363/1 "2016-09-23T10:24:58Z")

</div>

Hi, I am running the groovy script from JAVA which is something like this

> def value=DynamicValue  
> def Nvalue=NewValue  
> def field=Fieldvalue  
> def prod

> NewValue=NewValue.toInteger()  
> prod=doc[''+DynamicValue+''].value\*NewValue  
> if(doc[''+Fieldvalue+''].value != null)  
> {  
> doc[''+Fieldvalue+''].value=prod //here i am trying to update the field value  
> }

but when i am running the script i am getting an error like this

> {  
> "took" : 211,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 2,  
> "failed" : 3,  
> "failures" : [ {  
> "shard" : 0,  
> "index" : "jdbcdata",  
> "node" : "u9hIkU7HQDWqLXOoFSoLuQ",  
> "reason" : {  
> "type" : "script\_exception",  
> "reason" : "failed to run file script [fieldScript] using lang [groovy]",  
> "caused\_by" : {  
> "type" : "illegal\_argument\_exception",  
> "reason" : "argument type mismatch"  
> }  
> }  
> } ]  
> }

How do i update the value of the field ????

---

<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 5, 2017, 10:17pm UTC](https://discuss.elastic.co/t/update-value-of-a-field/61363/2 "2017-07-05T22:17:47Z")

</div>


