Is it possible to update an existing field in an index through mapping in Elasticsearch?

安稳与你 提交于 2020-01-11 13:17:09

问题


I've already created an index, and it contains data from my MySQL database. I've got few fields which are string in my table, where I need them as different types (integer & double) in Elasticsearch.

So I'm aware that I could do it through mapping as follows:

{
  "mappings": {
    "my_type": {
      "properties": {
        "userid": {
          "type": "text",
          "fielddata": true
        },
        "responsecode": {
          "type": "integer"
        },
        "chargeamount": {
          "type": "double"
        }
      }
    }
  }
} 

But I've tried this when I'm creating the index as a new one. What I wanted to know is how can I update an existing field (ie: chargeamount in this scenario) using mapping as a PUT?

Is this possible? Any help could be appreciated.


回答1:


Once a mapping type has been created, you're very constrained on what you can update. According to the official documentation, the only changes you can make to an existing mapping after it's been created are the following, but changing a field's type is not one of them:

In general, the mapping for existing fields cannot be updated. There are some exceptions to this rule. For instance:

  • new properties can be added to Object datatype fields.
  • new multi-fields can be added to existing fields.
  • doc_values can be disabled, but not enabled.
  • the ignore_above parameter can be updated.


来源:https://stackoverflow.com/questions/40354202/is-it-possible-to-update-an-existing-field-in-an-index-through-mapping-in-elasti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!