elasticsearch Elasticsearch位置数组的非法映射
我想在我的数据集上使用elasticsearch执行地理位置查询,如下所示:elasticsearch Elasticsearch位置数组的非法映射,elasticsearch,geolocation,mapping,elasticsearch,Geolocation,Mapping,我想在我的数据集上使用elasticsearch执行地理位置查询,如下所示: {"index": {"_index": "city","_type":"city_info", "_id":0} } {"fields": { "city" : "AGAWAM", "loc" : [ -72.622739, 42.070206 ], "pop" : 15338, "state" : "MA"}, "id" : "010
{"index": {"_index": "city","_type":"city_info", "_id":0} }
{"fields": { "city" : "AGAWAM",
"loc" : [ -72.622739, 42.070206 ],
"pop" : 15338, "state" : "MA"},
"id" : "01001" ,
"type" : "add"}
...
我能够执行很多查询或聚合,没有任何问题,但是当涉及到带有地理距离过滤器的查询或任何涉及地理坐标的查询时,它就不起作用了。以下是我的映射测试:
PUT /city/_mappings
{
"properties": {
"fields.loc": {
"type": "geo_point"
}
}
}
我得到这个错误
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "mapper [fields.loc] of different type, current_type [float], merged_type [geo_point]"
}
],
"type" : "illegal_argument_exception",
"reason" : "mapper [fields.loc] of different type, current_type [float], merged_type [geo_point]"
},
"status" : 400
}
因此,我的“fields.loc”似乎是一个浮点值,而在JSON中,它是一个数组,其中包含浮点值。我试图了解“loc”的实际类型,它确实是一个浮动,我不明白为什么:
GET /city/_mapping
所以我并不理解,或者更确切地说,我不知道如何将“loc”从浮点修改为geo_点。
由于我是elasticsearch的初学者,我只使用elasticsearch和kibana进行cURL。一旦您将数据类型隐式设置为float(通过批量同步,就像您可能做的那样),就很难将float转换为geo_点。 我建议删除索引,使用
geo_point
数据类型设置正确的映射,然后重新同步所有内容
如果您想深入了解,请查看api。这是一个例子。当您的系统在生产环境中运行时,您可能会遇到这种情况,而在生产环境中,拖放现在是一种选择
仅供参考,不推荐使用类型。谢谢!我已经做了你建议我做的第一件事:删除索引,用正确的映射设置一个新索引,其中“loc”类型为“geo_point”),然后再次批量同步。现在我的地理距离查询运行良好。很乐意帮忙!
{
"city" : {
"mappings" : {
"properties" : {
"fields" : {
"properties" : {
"city" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"loc" : {
"type" : "float"
...