# Question on upsert

**URL:** https://discuss.elastic.co/t/question-on-upsert/23023
**Category:** Elasticsearch
**Created:** [March 31, 2015, 11:10pm UTC](https://discuss.elastic.co/t/question-on-upsert/23023 "2015-03-31T23:10:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jae](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jae/32/791_2.png) [@Jae](https://discuss.elastic.co/u/Jae)
#### Post date: [March 31, 2015, 11:10pm UTC](https://discuss.elastic.co/t/question-on-upsert/23023/1 "2015-03-31T23:10:35Z")

</div>

Hi

I am using upsert bulk api with ES 1.4.1. The problem is, I get the  
following errors so frequently.

Error messages is

"error" -\> "ElasticsearchIllegalArgumentException[failed to execute  
script]; nested: GroovyScriptExecutionException[NullPointerException[Cannot  
execute null+null]]; "

and the upsert payload is

{  
"params": {  
"count": 1  
},  
"script": "ctx.\_source.logcount += count",  
"upsert": {  
"ts": 1427842500662,  
"logcount": 1,  
"EVENT\_TYPE": "NF\_ERRORS"  
}  
}

I stripped out a few fields to reduce the space.

When I retrieve the document from ES, I found something weird, the document  
is showing upsert payload itself.

{  
"\_index": "nf\_errors\_log20150331",  
"\_type": "default",  
"\_id":  
"23797375spider-i-c5a68429com.netflix.cloudservice.resources.JarVersions.JarVersionsController115",  
"\_version": 662,  
"found": true,  
"\_source": {  
"params": {  
"count": 1  
},  
"script": "ctx.\_source.logcount += count",  
"upsert": {  
"ts": 1427842522664,  
"logcount": 1,  
"EVENT\_TYPE": "NF\_ERRORS"  
}  
}  
}

Do you have any idea what I am doing wrong?

Thank you  
Best, Jae

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKe7ALeeagTNAzeVKaBzknvtHDEoBijSw71xdcsXvpuKCWiaVQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKe7ALeeagTNAzeVKaBzknvtHDEoBijSw71xdcsXvpuKCWiaVQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Jae](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jae/32/791_2.png) [@Jae](https://discuss.elastic.co/u/Jae)
#### Post date: [March 31, 2015, 11:38pm UTC](https://discuss.elastic.co/t/question-on-upsert/23023/2 "2015-03-31T23:38:12Z")

</div>

NVM, I found the problem.

On Tue, Mar 31, 2015 at 4:10 PM, Bae, Jae Hyeon [metacret@gmail.com](mailto:metacret@gmail.com) wrote:

> Hi
> 
> I am using upsert bulk api with ES 1.4.1. The problem is, I get the  
> following errors so frequently.
> 
> Error messages is
> 
> "error" -\> "ElasticsearchIllegalArgumentException[failed to execute  
> script]; nested: GroovyScriptExecutionException[NullPointerException[Cannot  
> execute null+null]]; "
> 
> and the upsert payload is
> 
> {  
> "params": {  
> "count": 1  
> },  
> "script": "ctx.\_source.logcount += count",  
> "upsert": {  
> "ts": 1427842500662,  
> "logcount": 1,  
> "EVENT\_TYPE": "NF\_ERRORS"  
> }  
> }
> 
> I stripped out a few fields to reduce the space.
> 
> When I retrieve the document from ES, I found something weird, the  
> document is showing upsert payload itself.
> 
> {  
> "\_index": "nf\_errors\_log20150331",  
> "\_type": "default",  
> "\_id":  
> "23797375spider-i-c5a68429com.netflix.cloudservice.resources.JarVersions.JarVersionsController115",  
> "\_version": 662,  
> "found": true,  
> "\_source": {  
> "params": {  
> "count": 1  
> },  
> "script": "ctx.\_source.logcount += count",  
> "upsert": {  
> "ts": 1427842522664,  
> "logcount": 1,  
> "EVENT\_TYPE": "NF\_ERRORS"  
> }  
> }  
> }
> 
> Do you have any idea what I am doing wrong?
> 
> Thank you  
> Best, Jae

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKe7ALffcsLjQQa4bmazYRMDux2jH6CqrQ2shnO40RQysyF13Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKe7ALffcsLjQQa4bmazYRMDux2jH6CqrQ2shnO40RQysyF13Q%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:22am UTC](https://discuss.elastic.co/t/question-on-upsert/23023/3 "2017-07-06T00:22:34Z")

</div>


