brunofl
February 18, 2023, 3:34pm
1
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?
brunofl
February 28, 2023, 10:33pm
2
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
system
(system)
Closed
March 28, 2023, 10:34pm
3
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.