# Update\_By\_Query in elasticsearch\_dsl matches \<field\> but doesn't match \<object\>.\<field\>

**URL:** <https://discuss.elastic.co/t/update-by-query-in-elasticsearch-dsl-matches-field-but-doesnt-match-object-field/325889>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [February 18, 2023, 3:34pm UTC](https://discuss.elastic.co/t/update-by-query-in-elasticsearch-dsl-matches-field-but-doesnt-match-object-field/325889 "2023-02-18T15:34:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![brunofl](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@brunofl](https://discuss.elastic.co/u/brunofl)\
**Post date:** [February 28, 2023, 10:33pm UTC](https://discuss.elastic.co/t/update-by-query-in-elasticsearch-dsl-matches-field-but-doesnt-match-object-field/325889/2 "2023-02-28T22:33:56Z")

</div>

Solved with the following:

```auto
update = ubq.script(source="ctx._source.object_name.field_name = params.new_ap_name; ctx._source.radio.Accesspoint_name = params.new_ap_name; ",
         lang="painless",
         params={ "new_ap_name": "new_field_value" }).update_from_dict({
                    "query": {
                           "bool": {
                                  "must": [
                                         { "match": { "object_name.field_name": "new_field_value" } },
                                         { "match": { "account_name": "Filters documents of specific customer" } }
                                   ]
                            }
                         }
}).params(request_timeout=3600).params(wait_for_completion=False).params(wait_for_active_shards=1).params(refresh=True)
response = update.execute()

```

The old and new field values can be provided by your python script.  
hope this helps

---

_[View the full topic](https://discuss.elastic.co/t/update-by-query-in-elasticsearch-dsl-matches-field-but-doesnt-match-object-field/325889)._
