Reputation: 4141
I have an index
with properties defined but in documents there is one property missing while importing from another elasticsearch.
Say, in index the mapping properties are:
"properties": {
"name": {"type" : ..},
"address": {"type" : ..},
"email": {"type" : ..}
}
But in documents, one of the property say email
is missing as:
{
"name": "Wheeler Walker",
"address": "Texas",
},
{
"name": "Kenny Rogers",
"address": "Virginia",
}
I have the property email
defined in mapping
already.
Now I just need to bulk update these documents so that email
property has ""
empty value.
How can I do that?
Upvotes: 0
Views: 289
Reputation: 22276
This is a classic case for updateByQuery.
Your request body should look roughly like this:
{
"query": {"bool": {"must_not: {"exists": {"field": "email"}}}},
"script": 'ctx._source.email = ""'
}
Upvotes: 2