是否可以通过Elasticsearch中的映射来更新索引中的现有字段? [英] Is it possible to update an existing field in an index through mapping in Elasticsearch?

查看:206
本文介绍了是否可以通过Elasticsearch中的映射来更新索引中的现有字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个索引,它包含来自我的 MySQL 数据库的数据。我的表中有几个字段为 string ,在那里我需要将它们作为不同的类型( integer & double )in Elasticsearch

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"
        }
      }
    }
  }
} 

但是当我将索引创建为新索引时,我已经尝试过了。我想知道的是如何使用 mapping 来更新现有字段(在这种情况下为 chargeamount PUT

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.

推荐答案

一旦创建了映射类型,您就无法更新任何内容。根据官方文档,创建现有映射后,您只能对其进行以下更改,但是更改字段类型不是其中之一:

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:


  • 可以将新属性添加到对象数据类型字段。

  • 新的多字段可以添加到现有字段中。

  • doc_values可以禁用,但不能启用。

  • 可以更新ignore_above参数。

  • 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.

这篇关于是否可以通过Elasticsearch中的映射来更新索引中的现有字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆