Facing issue while Update by Query With Upsert

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?

_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.

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