Mysql ElasticSearch PutMapping API:MapperParsingException根类型映射解析后不为空
我的本地ES1.3.4实例和MySql 1.3.4.4的JDBC实例上有一条河 这条河运行良好,正在ES中导入数据。我面临的问题是,我的一个字段是文本字段,其中有空格。例如“实时计算器”。ES将其索引为“实时”、“实时”和“计算器”,而不是“实时计算器” 因此,我使用下面提到的JSON创建映射:Mysql ElasticSearch PutMapping API:MapperParsingException根类型映射解析后不为空,mysql,elasticsearch,Mysql,elasticsearch,我的本地ES1.3.4实例和MySql 1.3.4.4的JDBC实例上有一条河 这条河运行良好,正在ES中导入数据。我面临的问题是,我的一个字段是文本字段,其中有空格。例如“实时计算器”。ES将其索引为“实时”、“实时”和“计算器”,而不是“实时计算器” 因此,我使用下面提到的JSON创建映射: { "sale_test": { "properties": { "Client": { "index": "not_an
{
"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\u type
curl -XPUT http://localhost:9200/my_index/_mapping/my_type
然后在JSON消息中变成sale\u 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/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"
}
}
}
}
}
}
谢谢这是打字问题。我得到了映射,在阅读了弹性搜索文档后,我意识到我们不能为已经创建的索引更新映射。我们需要先删除以前的映射,然后为此索引创建新映射。如果还有其他方法,请分享。谢谢
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"
}
}
}
}
}
}