[英]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.