19

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
  • 6,247
  • 3
  • 30
  • 50
Dibish
  • 9,133
  • 22
  • 64
  • 106
  • https://stackoverflow.com/questions/35350813/elasticsearch-how-do-you-delete-a-mapping-type-without-deleting-an-entire-index/57964499#57964499 – Kalpesh Soni Sep 16 '19 at 21:14

2 Answers2

20

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.

Community
  • 1
  • 1
bittusarkar
  • 6,247
  • 3
  • 30
  • 50
4

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

Chris Heald
  • 61,439
  • 10
  • 123
  • 137
  • The OP does not want to replace `status` field with another. Hence `multi_field` is not useful in this case. – bittusarkar Mar 05 '15 at 07:20
  • 2
    Understood. 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. – Chris Heald Mar 05 '15 at 07:22