I have a field field10 which got created by accident when I updated a particular record in my index. I want to remove this field from my index, all its contents and recreate it with the below mapping:
"mytype":{
"properties":{
"field10":{
"type":"string",
"index":"not_analyzed",
"include_in_all":"false",
"null_value":"null"
}
}
}
When I try to create this mapping using the Put Mapping API, I get an error: {"error":"MergeMappingException[Merge failed with failures {[mapper [field10] has different index values, mapper [field10] has different index_analyzer, mapper [field10] has different search_analyzer]}]","status":400}.
How do I change the mapping of this field? I don’t want to reindex millions of records just for this small accident.
Thanks
AFAIK, you can’t remove a single field and recreate it.
You can not either just modify a mapping and have everything reindexed automagicaly. Imagine that you don’t store
_source. How can Elasticsearch know what your data look like before it was indexed?But, you can probably modify your mapping using a multifield with
field10.field10using the old mapping andfield10.newwith the new analyzer.If you don’t reindex, only new documents will have content in
field10.new.If you want to manage old documents, you have to:
You can probably try to run a query like:
But, as you can see, you have to run it document by document and I think it will take more time than reindexing all with the Bulk API.
Does it help?