2014-04-07 19 views
0

我想,距離我的中心位置的最大距離在我elasticsearch查詢上geo_distance過濾,還有與分選部分沒有問題:在elasticsearch

{ 
    "query" : { 
     "match_all" : {} 
    }, 
    "sort" : [ 
     { 
      "_geo_distance" : { 
       "location" : "56,14", 
       "order" : "asc", 
       "unit"  : "km" 
      } 
     } 
    ] 
} 
然而

,當我嘗試添加一個過濾器,我得到"[geo_distance] filter does not support [location]"

{ 
    "query" : { 
     "filtered" : { 
      "query" : { 
       "match_all" : {} 
      }, 
      "filter" : { 
       "geo_distance" : { 
        "distance" : "200m", 
        "location" : { 
         "location" : "56,14" 
        } 
       } 
      } 
     } 
    }, 
    "sort" : [ 
     { 
      "_geo_distance" : { 
       "location" : "56,14", 
       "order" : "asc", 
       "unit"  : "km" 
      } 
     } 
    ] 
} 

任何想法我做錯了什麼?

+0

你可以試試「當前位置。位置「根據http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-filter.html#_lat_lon_as_string_4 – cfrick

+0

他們使用pin.location的原因是他們保存在一個次要的針的位置,我沒有保存我的位置在一個子這樣的 – Touchpad

回答

1

使用此過濾器,而不是

"filter" : { 
     "geo_distance" : { 
      "distance" : "200m", 
      "location" : "56,14" 
     } 
    } 

位置可以是一樣,如果你字段名稱是LOC或定位領域的任何名稱,那麼查詢將

"filter" : { 
      "geo_distance" : { 
       "distance" : "200m", 
       "loc"/"locator" : "56,14" 
      } 
     } 
+0

非常感謝,我完全錯過了那一個! – Touchpad