Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a field mapping in elastic search

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.

like image 256
Dibish Avatar asked Mar 05 '15 05:03

Dibish


People also ask

How do I remove something from Elasticsearch?

You use DELETE to remove a document from an index. You must specify the index name and document ID. You cannot send deletion requests directly to a data stream. To delete a document in a data stream, you must target the backing index containing the document.

How do you update a mapping field in Elasticsearch?

It is not possible to update the mapping of an existing field. If the mapping is set to the wrong type, re-creating the index with updated mapping and re-indexing is the only option available. In version 7.0, Elasticsearch has deprecated the document type and the default document type is set to _doc.

How do I turn off dynamic mapping in Elasticsearch?

You can disable dynamic mapping, both at the document and at the object level. Setting the dynamic parameter to false ignores new fields, and strict rejects the document if Elasticsearch encounters an unknown field. Use the update mapping API to update the dynamic setting on existing fields.

How do you delete an index in Elasticsearch?

To delete the index, you must roll over the data stream so a new write index is created. You can then use the delete index API to delete the previous write index.


1 Answers

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.

like image 156
bittusarkar Avatar answered Sep 19 '22 14:09

bittusarkar