Update_By_Query in elasticsearch_dsl matches <field> but doesn't match <object>.<field>

I managed to do an update_by_query script with elasticsearch_dsl.

response = ubq.script(source="pm_data_source.hw_alias' = params.new_ap_name",lang="painless",params={"new_ap_name": new_ap})\
        .query("match", pm_data_source.hw_alias = old_ap ).execute()

Current problem is: in the query() I am unable to match fields inside an object. Do you happen to know how to do this?

Solved with the following:

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

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