我的本地 ES 1.3.4 实例和 JDBC For MySql 1.3.4.4 上有一条 River
这条河流运行良好,正在 ES 中导入数据。我面临的问题是我的字段之一是文本字段并且其中有空格。例如“实时计算器”。 ES 将其索引为“真实”、“时间”和“计算器”,而不是“实时计算器”。
所以我使用下面提到的 JSON 创建映射:
{
"sale_test": {
"properties": {
"Client": {
"index": "not_analyzed",
"type": "string"
},
"OfferRGU": {
"type": "long"
},
"SaleDate": {
"format": "dateOptionalTime",
"type": "date"
},
"State": {
"type": "string"
}
}
}
}
和命令:
curl -XPUT http://localhost:9200/my_index/_mapping/my_type
但是我遇到了下面提到的错误:
> {"error":"MapperParsingException[Root type mapping not empty after
> parsing! Remaining fields: [sale_test :
> {properties={Client={type=string, index=not_analyzed},
> OfferRGU={type=long}, SaleDate={type=date, format=dateOptionalTime},
> State={type=string}}}]]","status":400}
当我尝试使用下面提到的命令查看当前映射时:
curl -XGET http://localhost:9200/dgses/sale_test_river/_mapping
我只得到这个:{}
感谢您的帮助。
最佳答案
你的类型不一致,在API调用中类型是my_type
curl -XPUT http://localhost:9200/my_index/_mapping/my_type
然后它变成 JSON 消息中的 sale_test。
拥有一致的类型将解决您的问题:
curl -XPUT http://localhost:9200/my_index/_mapping/sale_test -d '
{
"sale_test": {
"properties": {
"Client": {"type": "string", "index": "not_analyzed" },
"OfferRGU": { "type": "long" },
"SaleDate": { "type": "date", "format": "dateOptionalTime" },
"State": { "type": "string" }
}
}
}'
这里有一个新索引和一个新类型:
curl -XGET http://localhost:9200/dgses/sale_test_river/_mapping
更正索引和类型给我:
curl -XGET http://localhost:9200/my_index/sale_test/_mapping?pretty
{
"myindex" : {
"mappings" : {
"sale_test" : {
"properties" : {
"Client" : {
"type" : "string",
"index" : "not_analyzed"
},
"OfferRGU" : {
"type" : "long"
},
"SaleDate" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"State" : {
"type" : "string"
}
}
}
}
}
}
关于mysql - Elasticsearch PutMapping API : MapperParsingException Root type mapping not empty after parsing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27192553/