2014-05-08 112 views
1

我正在使用Python2.7,Google App Engine 1.9。*和Search API。 我存儲了啓用位置的興趣點。 現在我想實現GET,它返回給定位置的特定鄰近範圍內的所有興趣點。使用Google App Engine和Search API進行接近搜索

我在Google Search API Basics online document中找到的示例請參考排序的查詢結果。同樣的例子可以在github repo appengine-search-python-java找到完整的源代碼包。無論查詢字符串是什麼,找到的興趣點(例子中的商店)都按照最接近的順序列出。

也有一些例子說明如何限制某些數量的物品的返回值。 More Complex Search API Queries tutorial, section Query Options

search_query = search.Query(
query_string=query.strip(), 
options=search.QueryOptions(
    limit=doc_limit, 
... 

但是我的使用情況下,需要切斷是一種距離,而不是項目的硬一些。 有沒有人有這樣的例子?

回答

2

哎呀,沒有讀不夠密切,答案是在同一個地方 Location-Based Queries (Geosearch)

# a query string like this comes from the client 
query = "distance(store_location, geopoint(-33.857, 151.215)) < 45000" 
try: 
    index = search.Index(config.STORE_INDEX_NAME) 
    search_results = index.search(query) 
for doc in search_results: 
    # process doc ... 
except search.Error: 
    # ... 
相關問題