How to delete a field mapping in elastic search
Solution 1
You cannot delete the status
field from this mapping. If you really need to get rid of this field, you'll have to create another mapping without status
field and reindex your data. Look at this answer.
Solution 2
If you just need to change the mapping type on the status field, then you can't delete it, but you can change it to a multi_field
type, which indexes the field with multiple option sets.
Old data won't be indexed to the new field, but index requests moving forward will. In some use cases, it's a decently alternative for "delete the index and create a new one with a new mapping".
https://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/mapping-multi-field-type.html
Comments
-
Dibish over 4 years
I have an index with following mapping
{ "testmap": { "mappings": { "user": { "properties": { "plans": { "type": "nested", "properties": { "user": { "type": "long" } } }, "status": { "type": "integer" } } } } } }
I want to delete status field mapping. I don't mind to loose data on that field. Is there any option to delete status field. Tried
curl -XDELETE http://192.168.2.2:9200/testmap/user/status {"found":false,"_index":"testmap","_type":"user","_id":"status","_version":1
Your help is much appreciated. Thank you.
-
bittusarkar about 9 yearsThe OP does not want to replace
status
field with another. Hencemulti_field
is not useful in this case. -
Chris Heald about 9 yearsUnderstood. But the impetus for deleting a mapping is often to replace it with a different one;
multi_field
can frequently meet that need without having to recreate the entire mapping.