【问题标题】:How to update existing datatype of a field in elasticsearch ? ("No handler for type [text] declared on field [Name]")如何更新 elasticsearch 中字段的现有数据类型? (“没有在字段 [Name] 上声明的类型 [text] 的处理程序”)
【发布时间】:2017-08-04 22:41:37
【问题描述】:

我对弹性搜索完全陌生,想将一种现有的字段数据类型从“字符串”类型更新为“文本”类型。我试过但最终得到了这个异常:"No handler for type [text] declared on field [Name]"

任何建议,我的 elasticsearch 版本 -

{
  "name" : "Tej",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "raiQbq0ySUioBScsptsTzQ",
  "version" : {
    "number" : "2.4.4",
    "build_hash" : "fcbb46dfd45562a9cf00c604b30849a6dec6b017",
    "build_timestamp" : "2017-01-03T11:33:16Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.2"
  },
  "tagline" : "You Know, for Search"
}

索引映射细节 -

{"customer":{"mappings":{"external":{"properties":{"Name":{"type":"string"},"age":{"type":"long"},"doc":{"properties":{"age":{"type":"long"},"name":{"type":"string"}}},"name":{"type":"string"}}}}}}

根据文档 - 我使用以下命令更新现有数据类型

`curl -i -X PUT \
   -H "Content-Type:application/json" \
   -d \
'{
    "external" : {
        "properties" : {
            "Name" : {"type" : "text"}
        }
    }
}
' \
 'http://10.200.14.15:9200/customer/_mapping/external'`

回复

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "No handler for type [text] declared on field [Name]"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "No handler for type [text] declared on field [Name]"
    },
    "status": 400
}

【问题讨论】:

  • 你的弹性搜索版本是多少?
  • @Teja R 你想达到什么目的?你知道type: stringtype: text 之间的区别吗?否则我建议你阅读this。希望这会有所帮助!

标签: curl elasticsearch logstash


【解决方案1】:

您选择 Elasticsearch 2.4.4 的任何原因。而不是 5.X? 从您的集群名称来看,它是您个人的... 我问的原因是,字符串值在 5 中不再使用,并且映射也略有不同。

根据个人经验,如果现有字段中包含任何数据,则无法更改其映射。您应该能够使用新值更新映射模板,并且应该使用新值创建任何新模板。

如果要更改现有字段的类型,则必须使用新映射创建新索引,然后将旧索引中的所有数据迁移到新索引中。根据大小,这可能会很痛苦......

【讨论】:

    【解决方案2】:

    你得到这个的原因是,“文本”数据类型在 2.4 版本的 ElasticSearch 中不受支持。

    以下是支持的数据类型的完整列表:
    https://www.elastic.co/guide/en/elasticsearch/reference/2.4/mapping-types.html

    要么坚持“字符串”数据类型,要么升级您的 ElasticSearch。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-02
      • 1970-01-01
      • 1970-01-01
      • 2018-06-16
      • 1970-01-01
      • 1970-01-01
      • 2017-07-28
      相关资源
      最近更新 更多