3

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.

Strife
  • 243
  • 7
  • 22

1 Answers1

2

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.

Val
  • 207,596
  • 13
  • 358
  • 360