Need Help - with _update_by_query query several indexes for two fields (one is optional)

Need help- with _update_by_query to query several indexes for two fields (one is optional, for the indexes where the field exists).

I was doing two separate update by query, one when the index' document has a field common to all documents, and the other when need to update the same field, but in the query I need to update only the fields where second optional field exists and have a certain value.

The query I was using

GET /Index_pattern_*/_update_by_query
{
	"script": {
	    "source": "ctx._source.pm_data_source.hw_alias = 'newValue'",
	    "lang": "painless"
	  },
   "query" : { 
     "bool": {
        "must": [
        {"match" : {"pm_data_source.hw_alias": "oldValue"}},
        { "match": {"FieldThatSomeIndicesHave": "CertainValue"
                                                        }    }
        ]
    }}
}

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