如指南所述,
https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html#_mapping_options
我可以使用经纬度变量数组,并将其映射为geo_point类型。
所以这是我当前的映射:
{
"zoek": {
"mappings": {
"geo": {
"properties": {
"country": {
"type": "string"
},
"geonameid": {
"type": "string"
},
"locatie": {
"type": "double"
},
"name": {
"type": "string"
}
}
}
}
}
}
“locatie”是指两个double的数组。 [lat,lon]。
我想将此映射到geo_point变量以执行地理距离查询。
所以我尝试了这个:
PUT /zoek/geo/_mapping
{
"geo" : {
"properties" : {
"locatie" : {"type" : "geo_point" }
}
}
}
并得到此错误:
{
"error": "MergeMappingException[Merge failed with failures {[mapper [locatie] of different type, current_type [double], merged_type [geo_point]]}]",
“状态”:400
}
有什么建议么?
问候,
达格玛
最佳答案
在给定的映射类型(即geo
)中,您不能定义两个具有相同名称(即locatie
)但类型不同的字段(即一个字段为double
而另一个字段为geo_point
)。由于您的locatie
映射类型中已经有一个字段名geo
,因此您不能添加一个具有相同名称的新名称,但是可以肯定地添加另一个具有不同名称的名称,例如location_geo
。
但是,我建议更改原始映射,并用locatie
(如double
)替换locatie
(如geo_point
)。如果这样做,您将需要重新索引现有数据,因此这可能不是您的选择。
关于elasticsearch - Elasticsearch映射问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30324440/