【发布时间】:2020-03-16 22:55:28
【问题描述】:
我想在我的数据集上使用 elasticsearch 执行地理位置查询,如下所示:
{"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
{
"city" : {
"mappings" : {
"properties" : {
"fields" : {
"properties" : {
"city" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"loc" : {
"type" : "float"
...
所以我不明白,或者更确切地说,我不知道如何将“loc”从浮点数修改为 geo_point。 由于我是 elasticsearch 的初学者,我只使用 elasticsearch 和 kibana 进行 cURL。
【问题讨论】:
标签: elasticsearch geolocation mapping