Table of Contents
创建索引时报错
curl -X PUT "localhost:9200/ithothub.com?pretty" -H 'Content-Type: application/json' -d' { "settings" : { "number_of_shards" : 3, "number_of_replicas" : 1 }, "mappings" : { "properties": { "@timestamp": { "type": "date", "format": "strict_date_optional_time||epoch_millis" }, "message": { "type": "string", "index": "not_analyzed" } } } } ' { "error" : { "root_cause" : [ { "type" : "mapper_parsing_exception", "reason" : "No handler for type [string] declared on field [message]" } ], "type" : "mapper_parsing_exception", "reason" : "Failed to parse mapping [_doc]: No handler for type [string] declared on field [message]", "caused_by" : { "type" : "mapper_parsing_exception", "reason" : "No handler for type [string] declared on field [message]" } }, "status" : 400 }
原因分析
No handler for type [string] declared on field [message]
之前在老集群可以,估计是Elasticsearch新版本特性,果不其然,Elasticsearch从5.X就引入了text和keyword,其中keyword适用于不分词字段,搜索时只能完全匹配,这时string还保留着。
到了6.X就彻底移除string了。另外,”index”的值只能是boolean变量了。
解决方法
"message": { "type": "text", "index": false }
"message": { "type": "text", "index": false }
curl -X PUT "localhost:9200/ithothub.com?pretty" -H 'Content-Type: application/json' -d' { "settings" : { "number_of_shards" : 3, "number_of_replicas" : 1 }, "mappings" : { "properties": { "@timestamp": { "type": "date", "format": "strict_date_optional_time||epoch_millis" }, "message": { "type": "text", "index": false } } } } ' { "acknowledged" : true, "shards_acknowledged" : true, "index" : "ithothub.com" }
评论前必须登录!
注册