# Facing issue while Update by Query With Upsert

**URL:** <https://discuss.elastic.co/t/facing-issue-while-update-by-query-with-upsert/81252>\
**Category:** Elasticsearch\
**Created:** [April 5, 2017, 5:22am UTC](https://discuss.elastic.co/t/facing-issue-while-update-by-query-with-upsert/81252 "2017-04-05T05:22:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gautam\_Vanani](https://avatars.discourse-cdn.com/v4/letter/g/a9a28c/32.png) [@Gautam\_Vanani](https://discuss.elastic.co/u/Gautam_Vanani)\
**Post date:** [April 5, 2017, 5:22am UTC](https://discuss.elastic.co/t/facing-issue-while-update-by-query-with-upsert/81252/1 "2017-04-05T05:22:00Z")

</div>

Hi,  
I'm trying to use \_update\_by\_query with upsert but facing issue.

```
> POST /search_history/stone/_update_by_query
> {
> "script" : {
> "inline": "ctx._source.stone_ids.addAll(params.ids)",
> "lang": "painless",
> "params" : {
> "ids" : [4,5]
> }
> },
> "query":{
> "bool":{
> "must":[{
> "match":{
> "party_id":2
> }}]
> }
> }
> }

```

ERROR:  
\> {  
\> "error": {  
\> "root\_cause": [  
\> {  
\> "type": "parsing\_exception",  
\> "reason": "Unknown key for a START\_OBJECT in [upsert].",  
\> "line": 1,  
\> "col": 64  
\> }  
\> ],  
\> "type": "parsing\_exception",  
\> "reason": "Unknown key for a START\_OBJECT in [upsert].",  
\> "line": 1,  
\> "col": 64  
\> },  
\> "status": 400  
\> }

can anyone help me in this?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 5, 2017, 1:41pm UTC](https://discuss.elastic.co/t/facing-issue-while-update-by-query-with-upsert/81252/2 "2017-04-05T13:41:37Z")

</div>

`_update_by_query` doesn't support upsert. I'm not sure how you got upsert because the `_update_by_query` command you pasted doesn't mention it.

---

<div class="post-metadata">

**Author:** ![Gautam\_Vanani](https://avatars.discourse-cdn.com/v4/letter/g/a9a28c/32.png) [@Gautam\_Vanani](https://discuss.elastic.co/u/Gautam_Vanani)\
**Post date:** [April 5, 2017, 2:04pm UTC](https://discuss.elastic.co/t/facing-issue-while-update-by-query-with-upsert/81252/3 "2017-04-05T14:04:13Z")

</div>

@nik Is there any way to achieve functionality like upsert with update by query?

---

<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:** [May 3, 2017, 2:04pm UTC](https://discuss.elastic.co/t/facing-issue-while-update-by-query-with-upsert/81252/4 "2017-05-03T14:04:14Z")

</div>

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