【问题标题】:Change the mapping of a field in Kibana from String to Double将 Kibana 中字段的映射从 String 更改为 Double
【发布时间】:2019-04-23 11:55:49
【问题描述】:

我正在捕获实时数据流并对其进行处理。我配置了我的logstash.conf 文件。

我开始使用 ElasticSearch、Logstash 和 Kibana。

我在 kibana 中创建了我的索引,当我在开发工具中执行 get index 时,

我有这样的事情

    "message": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }    

我想将消息类型从 String 更改为 Double。我该怎么做?

【问题讨论】:

    标签: scala elasticsearch logstash spark-streaming kibana


    【解决方案1】:

    创建索引后,您无法更改映射 - 您必须自己在新索引中创建映射,明确创建所需的字段/类型: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html

    然后从旧索引重新索引到新索引: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html

    注意你想要的类型是'double'而不是'Double': https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html

    【讨论】:

      【解决方案2】:

      在 Elasticsearch(ES) 中更改字段的数据类型是一项重大更改。在您的情况下,您需要更新 ES 中的映射和更新。

      请使用https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html验证,映射在ES中更新成功。

      Reindex API 需要启用_source,请参阅https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html 了解有关_source 字段的更多信息以及您的情况是否已启用。

      如果在您的情况下未启用它,那么您唯一的选择是删除旧索引(具有旧映射)并使用新映射再次创建它。

      如果您对此有任何疑问或遇到任何问题,请告诉我。

      【讨论】:

      • 我创建了一个新索引,并对从 ElasticSearch 获得的数据使用了filter-mutate 功能。它奏效了。
      猜你喜欢
      • 2017-05-13
      • 1970-01-01
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      • 2018-07-29
      • 2014-03-09
      • 2019-10-03
      • 1970-01-01
      相关资源
      最近更新 更多