# Update call with a script doesn't work

**URL:** <https://discuss.elastic.co/t/update-call-with-a-script-doesnt-work/149756>\
**Category:** Elasticsearch\
**Created:** [September 25, 2018, 3:39am UTC](https://discuss.elastic.co/t/update-call-with-a-script-doesnt-work/149756 "2018-09-25T03:39:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![magedmakled](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magedmakled/32/69937_2.png) [@magedmakled](https://discuss.elastic.co/u/magedmakled)\
**Post date:** [September 25, 2018, 3:39am UTC](https://discuss.elastic.co/t/update-call-with-a-script-doesnt-work/149756/1 "2018-09-25T03:39:20Z")

</div>

I have a model `message_lists` that looks like

```auto
threads: nested
  thread_id: text
  read_all: boolean
  messages: nested
    message_id: text
    read: boolean
   body: text

```

When I run

```auto
/message_lists/message_list/xxxxxxxxxxx/_update
{
                                "script": {"inline": "for (thread in ctx._source.threads) { if (thread.thread_id == params.thread_id) { for (message in thread.messages){ if (message.message_id == params.message_id) { thread.read_all = params.read_all; message.read = true;}}}}",
                                 "lang": "painless",
                                 "params": {
                                    "thread_id": "vvvvvvvvvv",
                                    "message_id": "wwwwwwwww",
                                    "read_all": true
                                  }
                               }
                             }

```

The query run with no errors but the `read_all` field doesn't get set to true, is there something wrong with the 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:** [October 23, 2018, 3:39am UTC](https://discuss.elastic.co/t/update-call-with-a-script-doesnt-work/149756/2 "2018-10-23T03:39:21Z")

</div>

Closed on October 23, 2018, 3:39am UTC

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