Saa*_*han 5 mysql elasticsearch
我在我的本地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"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
和命令:
curl -XPUT http://localhost:9200/my_index/_mapping/my_type
Run Code Online (Sandbox Code Playgroud)
但我得到以下提到的错误:
> {"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}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用下面提到的命令查看当前映射时:
curl -XGET http://localhost:9200/dgses/sale_test_river/_mapping
Run Code Online (Sandbox Code Playgroud)
我只得到这个:{}
谢谢你的帮助.
您的类型不一致,在API调用中类型为my_type
curl -XPUT http://localhost:9200/my_index/_mapping/my_type
Run Code Online (Sandbox Code Playgroud)
然后它在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" }
}
}
}'
Run Code Online (Sandbox Code Playgroud)
这里有新索引和新类型:
curl -XGET http://localhost:9200/dgses/sale_test_river/_mapping
Run Code Online (Sandbox Code Playgroud)
纠正索引和类型给了我:
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"
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)