Have an Elasticsearch mapping similar to the one below and I'm trying to update it using the re-index API. I've learned how to use of pipelines to do various things such remove fields or change types, however nothing on removing fields from nested types. For instance, in the descriptions field how would I setup a pipeline to remove the badfield?
{
"mappings": {
"all": {
"_all": {
"enabled": false
},
"dynamic": "strict",
"properties": {
"address": {
"type": "text"
},
"businessName": {
"type": "text"
},
"descriptions": {
"type": "nested",
"properties": {
"dateSeen": {
"type": "date",
"format": "date_time"
},
"source": {
"type": "text",
},
"value": {
"type": "text"
},
"badfield": {
"type": "text"
}
}
},
"dateAdded": {
"type": "date",
"format": "date_time||date_time_no_millis"
}
}
}
}
}
Documentation on removing a field using the removing fields
Using ES 6 btw.
I setup a processor script based on a comment and running into issues where the field is null even though its plainly there.
{
"processors": [{
"script": {
"source": """
if (ctx._source.descriptions != null) {
for(item in ctx._source.descriptions) {
item.remove('badfield');
}
}
"""
}
}
]
}
EDIT: removing _source from the script was the issue, which means I don't fully understand its usage but was able to create a nested field removal script.