gpt4 book ai didi

ruby-on-rails - ElasticSearch geo_bounding_box坐标格式

转载 作者:行者123 更新时间:2023-12-02 22:47:26 25 4
gpt4 key购买 nike

我在网上遵循ElasticSearch指南,将坐标表示为“lat,lng”,但是直到我将所有内容都翻转为“lng,lat”后,它似乎才起作用。我什至必须翻转top_left和bottom_right才能使查询正常工作。

有人遇到同样的问题吗?显然,这不是文档所说的使用方式,但是只有当我以这种方式格式化时,它才起作用。

Rails格式

def self.search(params)
tire.search( page: params[:page], per_page: 2 ) do
query { all }
filter :geo_bounding_box, location: { top_left: " -121.88596979687497, 37.33588487375733", bottom_right: " -122.43528620312497, 37.553946238118264" }
end
end

CURL格式
curl -X GET "http://localhost:9200/articles/article/_search?page=&per_page=2&size=2&pretty=true" -d '{"query":{"match_all":{}},"facets":{"condition":{"terms":{"field":"condition","size":10,"all_terms":false}}},"filter":{"geo_bounding_box":{"location":{"top_left":" -121.88596979687497, 37.33588487375733","bottom_right":" -122.43528620312497, 37.553946238118264"}}},"size":2}'

控制台响应
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 169,
"max_score" : 1.0,
"hits" : [ {
"_index" : "articles",
"_type" : "article",
"_id" : "4f72bc7d0bdb820f02000002",
"_score" : 1.0, "_source" : {"content":"words here!","location":[37.444995,-122.160628],"name":"harro"}
}, {
"_index" : "articles",
"_type" : "article",
"_id" : "4fdf0cf20bdb82336c000002",
"_score" : 1.0, "_source" : {"content":"Run of the mill","location":[37.33588487375733,-121.88596979687497],"name":"Billy Bob"}
} ]
},
"facets" : {
"condition" : {
"_type" : "terms",
"missing" : 5597,
"total" : 0,
"other" : 0,
"terms" : [ ]
}
}

最佳答案

如果将地理点指定为字符串,则它应采用"lat,lon"格式。当将其指定为数组时,应采用[lon, lat]格式。

关于ruby-on-rails - ElasticSearch geo_bounding_box坐标格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11130266/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com