简体   繁体   English

如何在Elasticsearch中更新字段的现有数据类型? (“没有在字段[名称]上声明类型[文本]的处理程序”)

[英]How to update existing datatype of a field in elasticsearch ? (“No handler for type [text] declared on field [Name]”)

I am completely new to elasticsearch want to update one existing field datatype from "string" type to "text" type. 我对Elasticsearch完全陌生,希望将一种现有的字段数据类型从“字符串”类型更新为“文本”类型。 I have tried but ended up getting this exception: "No handler for type [text] declared on field [Name]" 我已经尝试过,但最终遇到以下异常: "No handler for type [text] declared on field [Name]"

Any advice, my elasticsearch version - 任何建议,我的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"
}

Index Mapping detail - 索引映射详细信息-

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

As per the doc - I used below command to update existing datatype 根据文档-我使用以下命令更新现有数据类型

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

response 响应

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

Any reason why you went for Elasticsearch 2.4.4. 选择Elasticsearch 2.4.4的任何理由。 instead of 5.X? 而不是5.X? Judging by the name of your cluster, it is your personal one... Reason I ask, is that the string value is no longer in use in 5, and the mappings are done slightly different as well. 从集群的名称来看,它是您的个人名字。。。我问,原因是字符串值在5中不再使用,并且映射也略有不同。

From personal experience, you cannot change the mapping of an existing field if it has any data in it. 根据个人经验,如果现有字段中包含任何数据,则无法更改它的映射。 You should be able to update your mapping template with the new value, and any new template should be created with the new value. 您应该能够使用新值更新映射模板,并且应该使用新值创建任何新模板。

If you want to change the type of an existing field, you will have to create a new index, with the new mapping and then migrate all data from the old one in the new one. 如果要更改现有字段的类型,则必须使用新映射创建一个新索引,然后将旧索引中的所有数据迁移到新索引中。 Depending on the size, this can be quite a pain in the... 根据大小,这可能会给您带来很大的痛苦。

The reason you are getting this is because, the "Text" datatype is not supported in the 2.4 version of ElasticSearch. 得到这个的原因是,ElasticSearch的2.4版本不支持“文本”数据类型。

Here is the complete list of supported datatypes: 这是受支持的数据类型的完整列表:
https://www.elastic.co/guide/en/elasticsearch/reference/2.4/mapping-types.html https://www.elastic.co/guide/en/elasticsearch/reference/2.4/mapping-types.html

Either stick to "string" datatype or upgrade your ElasticSearch. 坚持使用“字符串”数据类型或升级您的ElasticSearch。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Elasticsearch:没有在字段上声明类型[文本]的处理程序 - Elasticsearch: No handler for type [text] declared on field 如何使用elasticsearch python中的特定字段名称从多个索引中删除文档? - How to delete documents from multiple indices using particular field name in elasticsearch python? 联接字段(多类型索引错误)-Elasticsearch - Join field (Multi-type index error) - Elasticsearch 如何从Elasticsearch索引中的两个字段派生一个字段? - How to derive a field from two fields in an Elasticsearch index? 范围查询不支持Elasticsearch字段 - Elasticsearch field not supported in range query Elasticsearch查询中的排除给出了无法解析搜索源的信息。 预期的字段名称,但获得了[START_OBJECT] - Exclude in elasticsearch query gives failed to parse search source. expected field name but got [START_OBJECT] Elasticsearch 查询问题 - [范围] 格式错误的查询,预期为 [END_OBJECT],但发现 [FIELD_NAME] - Problem with Elasticsearch query - [range] malformed query, expected [END_OBJECT] but found [FIELD_NAME] Elasticsearch 6创建新字段需要数据类型,但“在6.x中创建的索引仅允许每个索引使用单一类型” - Elasticsearch 6 create new field requires data type but “Indices created in 6.x only allow a single-type per index” Elasticsearch 索引时间戳字段失败 - Elasticsearch indexing timestamp-field fails 在Elasticsearch中将多个自定义分析器设置为单个字段 - Setting multiple custom analyzers to single field in elasticsearch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM