# Partial update error. Reason: "Left-hand side cannot be assigned a value."

**URL:** <https://discuss.elastic.co/t/partial-update-error-reason-left-hand-side-cannot-be-assigned-a-value/117100>\
**Category:** Kibana\
**Created:** [January 25, 2018, 6:43pm UTC](https://discuss.elastic.co/t/partial-update-error-reason-left-hand-side-cannot-be-assigned-a-value/117100 "2018-01-25T18:43:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dr\_dob](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dr\_dob](https://discuss.elastic.co/u/dr_dob)\
**Post date:** [January 25, 2018, 6:43pm UTC](https://discuss.elastic.co/t/partial-update-error-reason-left-hand-side-cannot-be-assigned-a-value/117100/1 "2018-01-25T18:43:05Z")

</div>

Hi

I'm trying to update an index-pattern in .kibana to contain another scripted field. In testing partial update of the document field I get an error. The partial update was the following:

curl -XPOST 'localhost:9200/.kibana/doc/index-pattern:5cd01980-e173-11e7-b90c-9930744e76ad/\_update?pretty' -H 'Content-Type: application/json' -d'  
{  
"script" : "ctx.\_source.index\u002Dpattern.title = \u0027pddd\u0027"  
}  
'

but it returned the following:

{  
"error" : {  
"root\_cause" : [  
{  
"type" : "remote\_transport\_exception",  
"reason" : "[\_Mtk082][127.0.0.1:9300][indices:data/write/update[s]]"  
}  
],  
"type" : "illegal\_argument\_exception",  
"reason" : "failed to execute script",  
"caused\_by" : {  
"type" : "script\_exception",  
"reason" : "compile error",  
"script\_stack" : [],  
"script" : "ctx.\_source.index-pattern.title = 'pddd'",  
"lang" : "painless",  
"caused\_by" : {  
"type" : "illegal\_argument\_exception",  
"reason" : "Left-hand side cannot be assigned a value."  
}  
}  
},  
"status" : 400  
}

Any ideas why?

---

<div class="post-metadata">

**Author:** ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)\
**Post date:** [January 25, 2018, 7:35pm UTC](https://discuss.elastic.co/t/partial-update-error-reason-left-hand-side-cannot-be-assigned-a-value/117100/2 "2018-01-25T19:35:55Z")

</div>

Have you tried updating this index pattern in the UI? [https://www.elastic.co/guide/en/kibana/current/scripted-fields.html](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html)

---

<div class="post-metadata">

**Author:** ![dr\_dob](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dr\_dob](https://discuss.elastic.co/u/dr_dob)\
**Post date:** [January 25, 2018, 9:17pm UTC](https://discuss.elastic.co/t/partial-update-error-reason-left-hand-side-cannot-be-assigned-a-value/117100/3 "2018-01-25T21:17:23Z")

</div>

I'm trying to automate the creation of scripted fields, so using the UI is not an option

---

<div class="post-metadata">

**Author:** ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)\
**Post date:** [January 25, 2018, 9:42pm UTC](https://discuss.elastic.co/t/partial-update-error-reason-left-hand-side-cannot-be-assigned-a-value/117100/4 "2018-01-25T21:42:31Z")

</div>

So that error is thrown by the Painless compiler trying to compile that script. I think it is trying to run your script rather than taking that as an update to the index-pattern. The saved object looks like this:

```
{
  "_index": ".kibana",
  "_type": "doc",
  "_id": "index-pattern:949c2fc0-0216-11e8-ba5f-d90822c14a01",
  "_version": 3,
  "found": true,
  "_source": {
    "type": "index-pattern",
    "updated_at": "2018-01-25T21:28:54.558Z",
    "index-pattern": {
      "title": "billy*",
      "fields": """[{"name":"_id","type":"string","count":0,"scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":false},{"name":"_index","type":"string","count":0,"scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":false},{"name":"_score","type":"number","count":0,"scripted":false,"searchable":false,"aggregatable":false,"readFromDocValues":false},{"name":"_source","type":"_source","count":0,"scripted":false,"searchable":false,"aggregatable":false,"readFromDocValues":false},{"name":"_type","type":"string","count":0,"scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":false},{"name":"billy","type":"string","count":0,"scripted":false,"searchable":true,"aggregatable":false,"readFromDocValues":false},{"name":"billy.keyword","type":"string","count":0,"scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":true},{"name":"script","type":"number","count":0,"scripted":true,"script":"doc['billy']","lang":"painless","searchable":true,"aggregatable":true,"readFromDocValues":false}]"""
    }
  }
}

```

I think you would need to update the "fields" field in the \_source field and append your new scripted field to that array.

Maybe you could explain in more detail what you are trying to do.

---

<div class="post-metadata">

**Author:** ![dr\_dob](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dr\_dob](https://discuss.elastic.co/u/dr_dob)\
**Post date:** [January 26, 2018, 1:57am UTC](https://discuss.elastic.co/t/partial-update-error-reason-left-hand-side-cannot-be-assigned-a-value/117100/5 "2018-01-26T01:57:39Z")

</div>

I'm trying to do exactly as you said. Perform a partial update to update .\_source.index-pattern.fields with the appended scripted field. But I believe the problem is index-pattern contains a hash-minus, so "script" : "ctx.\_source.index-pattern.fields" throws an error. I tried using Unicode \u002D as a replacement, but it still doesn't work.

---

<div class="post-metadata">

**Author:** ![Bill\_McConaghy](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Bill\_McConaghy](https://discuss.elastic.co/u/Bill_McConaghy)\
**Post date:** [January 26, 2018, 1:27pm UTC](https://discuss.elastic.co/t/partial-update-error-reason-left-hand-side-cannot-be-assigned-a-value/117100/6 "2018-01-26T13:27:33Z")

</div>

If that is the case, you could try this style of accessing the field:  
obj['attr']  
This might sort out your 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 23, 2018, 1:27pm UTC](https://discuss.elastic.co/t/partial-update-error-reason-left-hand-side-cannot-be-assigned-a-value/117100/7 "2018-02-23T13:27:46Z")

</div>

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