1

オンラインで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 -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

1 に答える 1

4

ジオポイントが文字列として指定されている場合、それは"lat,lon"形式である必要があります。配列として指定する場合は、[lon, lat]形式にする必要があります。

于 2012-06-21T01:46:35.083 に答える