在使用官方文档案例
PUT /my_store
{
"mappings" : {
"products" : {
"properties" : {
"productID" : {
"type" : "string",
"index":"not_analyzed"
}
}
}
}
}
时报错:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "No handler for type [string] declared on field [productID]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [products]: No handler for type [string] declared on field [productID]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "No handler for type [string] declared on field [productID]"
}
},
"status": 400
}
看你下载的ES是哪个版本,5.x以上已经没有string类型。如果需要分词的话使用text,不需要分词使用keyword。
具体可以参考这篇博文:http://blog.csdn.net/paditang/article/details/78949233
另:官方中文文档比较滞后,建议查看英文文档
No handler for type [string] declared on field [productID]"
看看你的productID 属性是不是正确的,type的类型是不是string
https://www.cnblogs.com/zhaijunming5/p/6426940.html
http://blog.csdn.net/napoay/article/details/52012249
你用的是什么版本的ElasticSearch,5.X以上版本没有string类型了,换成了text和keyword作为字符串类型。
请参考官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html