I'm using elasticsearch 7.10 and have an index with mapping as follows:
{
"test_index" : {
"mappings" : {
"properties" : {
"packages" : {
"type" : "nested",
"include_in_root" : true,
"properties" : {
"amount" : {
"type" : "text",
"fields" : {
"raw" : {
"type" : "double"
}
}
},
"rem_amount" : {
"type" : "keyword",
"fields" : {
"raw" : {
"type" : "double"
}
}
}
}
}
}
}
}
}
I've also indexed some documents to the index with the above mapping. Now I want to remove field "rem_amount" from mapping and the associated documents.
Is there any way that I can update the mapping to remove a field WITHOUT reindexing the entire index?
The elastic search put mapping API doc does not mention any such thing and I wonder if it is even possible. https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html
A similar question was asked way back in 2016 but want to know if any changes have been made to the way a field can be deleted without reindexing.
No, you can't, it's still not possible to remove a field from a mapping, the only way is to reindex.
You can definitely remove the field from all your documents using the _update_by_query API, but the field will stay in the mapping. I'm not sure how problematic that is to still have a field in your mapping that no document has, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With