当尝试从我的索引中的记录动态地从纬度中进行搜索时,我得到了一个非法的纬度值。在查看我的索引时,我看不到任何无效的纬度和经度值,所以我猜这是代码中的错误。
精确误差;
{"type":"query_parsing_exception","reason":"illegal latitude value [269.99999983236194] for [geo_distance]","index":"addresses","line":1,"col":172}}]},"status":400}用于搜索的模型代码;
def self.search(query)
__elasticsearch__.search(
{
query:{
multi_match: {
query: query,
fields: ['full_address']
}
},
filter:{
geo_distance:{
distance: "6miles",
location: "address.location"
}
}
}
)
end映射;
{ "addresses" : {
"mappings" : {
"address" : {
"properties" : {
"county" : {
"type" : "string"
},
"full_address" : {
"type" : "string"
},
"location" : {
"type" : "geo_point"
}
}
}
}}}
发布于 2016-09-30 22:31:00
我今天遇到了同样的错误,但与经度有关。结果是Elasticsearch 2.0版和更新版本只允许-180..180范围内的经度值。
例如,版本1.7.5 (我在本地环境中使用的版本)适用于两个范围- -180..180和0..360。
您的错误状态为:
非法纬度值269.99999983236194
对于纬度,仅允许范围为-90..90的值。
唯一的修复方法是在将它们发送到Elasticsearch之前重新计算经度/经度值。例如,对于经度,您可以这样做:
((longitude.to_f + 180) % 360) - 180发布于 2016-12-14 01:11:17
最好用下面这样的代码来清理经度:
$adjustedLongitude = function($vongitude) {
$result = $vongitude - 360 * floor($vongitude / 360);
if (abs($result) > 180) {
$result = 360 - $result;
}
return $result;
}https://stackoverflow.com/questions/34907078
复制相似问题