# \[Pig\] Error when using es.update.script with upsert

**URL:** <https://discuss.elastic.co/t/pig-error-when-using-es-update-script-with-upsert/70491>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [January 4, 2017, 12:14am UTC](https://discuss.elastic.co/t/pig-error-when-using-es-update-script-with-upsert/70491 "2017-01-04T00:14:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![svellanki](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@svellanki](https://discuss.elastic.co/u/svellanki)\
**Post date:** [January 4, 2017, 12:14am UTC](https://discuss.elastic.co/t/pig-error-when-using-es-update-script-with-upsert/70491/1 "2017-01-04T00:14:25Z")

</div>

In my Pig script I have  
`STORE dd_info INTO '$ES_INDEX/$ES_TYPE' USING org.elasticsearch.hadoop.pig.EsStorage('es.resource.write=$ES_INDEX/$ES_TYPE', 'es.write.operation=upsert', 'es.update.script=dd', 'es.update.script.params=count:count', 'es.nodes=$ES_NODE', 'es.mapping.id=docId');`

The elasticsearch/config/scripts/dd.groovy file contents:  
`ctx._source.count += count`

Did I get the es.update.script value right? The [configuration](https://www.elastic.co/guide/en/elasticsearch/hadoop/current/configuration.html) says it mirrors the [update API](https://www.elastic.co/guide/en/elasticsearch/reference/2.0/docs-update.html), but I couldn't find any examples that use the script from a file. Any help is appreciated.

Stack trace below:  
Error: Failure while running task:org.elasticsearch.hadoop.rest.EsHadoopInvalidRequest: Found unrecoverable error [] returned Bad Request(400) - failed to execute script; Bailing out..  
at org.elasticsearch.hadoop.rest.RestClient.processBulkResponse(RestClient.java:250)  
at org.elasticsearch.hadoop.rest.RestClient.bulk(RestClient.java:202)  
at org.elasticsearch.hadoop.rest.RestRepository.tryFlush(RestRepository.java:220)  
at org.elasticsearch.hadoop.rest.RestRepository.flush(RestRepository.java:242)  
at org.elasticsearch.hadoop.rest.RestRepository.doWriteToIndex(RestRepository.java:196)  
at org.elasticsearch.hadoop.rest.RestRepository.writeToIndex(RestRepository.java:159)  
at org.elasticsearch.hadoop.mr.EsOutputFormat$EsRecordWriter.write(EsOutputFormat.java:151)  
at org.elasticsearch.hadoop.pig.EsStorage.putNext(EsStorage.java:189)  
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat$PigRecordWriter.write(PigOutputFormat.java:136)  
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat$PigRecordWriter.write(PigOutputFormat.java:95)  
at org.apache.tez.mapreduce.output.MROutput$1.write(MROutput.java:503)  
at org.apache.pig.backend.hadoop.executionengine.tez.plan.operator.POStoreTez.getNextTuple(POStoreTez.java:129)  
at org.apache.pig.backend.hadoop.executionengine.tez.runtime.PigProcessor.runPipeline(PigProcessor.java:378)  
at org.apache.pig.backend.hadoop.executionengine.tez.runtime.PigProcessor.run(PigProcessor.java:243)  
at org.apache.tez.runtime.LogicalIOProcessorRuntimeTask.run(LogicalIOProcessorRuntimeTask.java:362)  
at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable$1.run(TezTaskRunner.java:192)  
at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable$1.run(TezTaskRunner.java:184)  
at java.security.AccessController.doPrivileged(Native Method)  
at javax.security.auth.Subject.doAs(Subject.java:422)  
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1738)  
at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable.callInternal(TezTaskRunner.java:184)  
at org.apache.tez.runtime.task.TezTaskRunner$TaskRunnerCallable.callInternal(TezTaskRunner.java:180)  
at org.apache.tez.common.CallableWithNdc.call(CallableWithNdc.java:36)  
at java.util.concurrent.FutureTask.run(FutureTask.java:266)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
at java.lang.Thread.run(Thread.java:745)

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [January 16, 2017, 8:26pm UTC](https://discuss.elastic.co/t/pig-error-when-using-es-update-script-with-upsert/70491/2 "2017-01-16T20:26:57Z")

</div>

@svellanki you are correct in the formatting of your script property, but at this moment, ES-Hadoop does not support file based script usage. I have opened [https://github.com/elastic/elasticsearch-hadoop/issues/918](https://github.com/elastic/elasticsearch-hadoop/issues/918) to track this. Thanks for your post highlighting this issue!

---

<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 13, 2017, 8:27pm UTC](https://discuss.elastic.co/t/pig-error-when-using-es-update-script-with-upsert/70491/3 "2017-02-13T20:27:23Z")

</div>

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