2012-06-21 2 views
1

좌표를 "lat, lng"로 나타 내기 위해 ElasticSearch 가이드를 온라인으로 따라했지만 "lng, lat"로 모든 것을 뒤집을 때까지 작동하지 않는 것 같습니다. 나는 심지어 쿼리를 작동시키기 위해서 top_left와 bottom_right 주위를 뒤집어 써야한다.ElasticSearch geo_bounding_box 좌표 형식

같은 문제가 발생하는 사람이 있습니까? 분명히 이것은 설명서가 그것을 사용하는 방법은 아니지만이 방법으로 포맷 할 때만 작동합니다.

레일 형식

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" : [ ] 
    } 
    } 

답변

4

, 그것은 "lat,lon" 형식이어야합니다. 어레이로 지정되면 [lon, lat] 형식이어야합니다.

+0

당신은 그것을 못 박았습니다. 당신의 도움을 주셔서 감사합니다! –

+0

이유가 무엇인가요? 어긋나게 들립니다. –

+0

문자열 표현은 지리적 좌표에 대한 표준 규칙을 따르고 배열 표현은 [GeoJSON] (http://www.geojson.org/) 표준을 따릅니다. [stackexchange에 대한 흥미로운 토론] (http://gis.stackexchange.com/questions/6037/latlon-or-lonlat-whats-the-right-way-to-display-coordinates-and-inputs)에 대한 내용이 있습니다. 이러한 차이에 대한 역사적인 이유. – imotov