Reputation: 1197
I want to re index an index and during this process i want to lowercase values of all the fields. Is there any way i can do this.
Currently i have looked into the ingest pipeline but in it you have to name each field that needs to be converted to lowercase.
{
"lowercase": {
"field": "foo"
}
}
I want something that can lowercase values of all fields without need to mentioning the name of fields.
Upvotes: 1
Views: 1652
Reputation: 217474
I'd suggest to use scripting when calling the Reindex API. In the script you can iterate over all fields and lowercase their value. Something like this should work:
POST _reindex
{
"source": {
"index": "source_index"
},
"dest": {
"index": "target_index"
},
"script": {
"source": "ctx._source.forEach((field, value) -> ctx._source[field] = value?.toLowerCase())}",
"lang": "painless"
}
}
Upvotes: 4