# Updating value of nested field with update\_by\_query API

**URL:** <https://discuss.elastic.co/t/updating-value-of-nested-field-with-update-by-query-api/107529>\
**Category:** Elasticsearch\
**Created:** [November 14, 2017, 10:28am UTC](https://discuss.elastic.co/t/updating-value-of-nested-field-with-update-by-query-api/107529 "2017-11-14T10:28:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_Shah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_shah/32/20805_2.png) [@Amit\_Shah](https://discuss.elastic.co/u/Amit_Shah)\
**Post date:** [November 14, 2017, 10:28am UTC](https://discuss.elastic.co/t/updating-value-of-nested-field-with-update-by-query-api/107529/1 "2017-11-14T10:28:44Z")

</div>

Hi experts,

I am looking to run \_update\_by\_query where i intend to update a field in nested object (commenter\_types.ctype) with the value of other element in same nested object (commenter\_types.commenter\_type)

```
POST mention_usersv2/_update_by_query
{
  "script": {
    "inline": "ctx._source.commenter_types.ctype = ctx._source.commenter_types.commenter_type",
    "lang": "painless"
  },
  "query": {
    "constant_score" : {
        "filter" : {
            "exists" : { "field" : "commenter_types" }
        }
    }
  }
}

```

When i give in the above query - it unfortunately dont update. Can anyone guide in as if in case one want to achieve the above, how can we?

---

<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:** [December 12, 2017, 10:29am UTC](https://discuss.elastic.co/t/updating-value-of-nested-field-with-update-by-query-api/107529/2 "2017-12-12T10:29:12Z")

</div>

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