2015-12-29 31 views
1
{ 
    "geo_bounding_box": { 
    "location": { 
     "top_right": { 
     "lat": 4.482137, 
     "lon": 51.0355306 
     }, 
     "bottom_left": { 
     "lat": 4.482137, 
     "lon": 51.0146768 
     } 
    } 
    } 
} . 

轉換上述搜索過濾器,以彈性搜索查詢DSL(Python)的如何在彈性搜索中構建搜索查詢在python中查詢地理點的DSL?

+0

我可以應用直接過濾器。但無法找到geo_points的方法? – user2883376

+0

.filter(「geo_bounding_box」,location = {「top_right」:{「lat」:4.482137,「lon」:51.0355306}, 「bottom_left」:{「lat」:4.482137,「lon」:51.0146768}})。 – user2883376

回答

0

.filter( 「geo_bounding_box」,位置= { 「TOP_RIGHT」:{ 「LAT」:4.482137, 「LON」:51.0355306} ,「bottom_left」:{「lat」:4.482137,「lon」:51.0146768}})。

這將工作!

3

如果你看一下source code,你會發現geo_bounding_box filter,你的腳本應該是這個樣子

from elasticsearch import Elasticsearch 
from elasticsearch_dsl import Search 

client = Elasticsearch() 

s = Search(using=client, index="my_index") \ 
    .filter("geo_bounding_box", location={ 
      "top_right": { 
       "lat": 4.482137, 
       "lon": 51.0355306 
      }, 
      "bottom_left": { 
       "lat": 4.482137, 
       "lon": 51.0146768 
      } 
      }) 

希望這有助於!

+0

非常感謝,正在尋找這個。有沒有辦法通過從'from elasticsearch_dsl.query import Query'繼承來將它寫成類? –