位置数组的 Elasticsearch 非法映射
Elasticsearch illegal mapping of a location array
我想在我的数据集上使用 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。
一旦您将数据类型隐式设置为浮点数(通过批量同步,就像您可能所做的那样),将很难将浮点数转换为 geo_points。
我建议删除索引,使用 geo_point
数据类型设置正确的映射并重新同步所有内容。
如果您想深入了解,请查看 _reindex
api. Here's a quick tut。当您的系统在现在可以选择删除的生产环境中运行时,您可能会遇到这种情况。
仅供参考,不推荐使用 custom _doc 类型。
我想在我的数据集上使用 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。
一旦您将数据类型隐式设置为浮点数(通过批量同步,就像您可能所做的那样),将很难将浮点数转换为 geo_points。
我建议删除索引,使用 geo_point
数据类型设置正确的映射并重新同步所有内容。
如果您想深入了解,请查看 _reindex
api. Here's a quick tut。当您的系统在现在可以选择删除的生产环境中运行时,您可能会遇到这种情况。
仅供参考,不推荐使用 custom _doc 类型。