2

我想使用的應用程序引擎的搜索API來搜索地點: https://developers.google.com/appengine/docs/python/search/overview#Performing_Location-Based_Searches爲什麼地理搜索/基於位置的搜索返回零結果?

的問題是,無論我做什麼,我得到結果爲零。我將搜索lat/lng設置爲文檔的GeoPoint屬性上的確切點,並且它仍然返回零。

我知道常規搜索正在工作,因爲如果我將查詢更改爲常規全文搜索,它就會起作用。

這裏是我的數據的例子(這實際上是從示例應用程序的位置:http://www.youtube.com/watch?v=cE6gb5pqr1k

Full Text Search > stores1 
Document Id: sanjose 
Field Name Field Value 
store_address 123 Main St. 
store_location search.GeoPoint(latitude=37.37, longitude=-121.92) 
store_name San Jose 

,然後是查詢:

index = search.Index('stores1') 
loc = (37.37, -121.92) 
query = "distance(store_location, geopoint(37.37, -121.92)) < 4500" 
loc_expr = "distance(store_location, geopoint(37.37, -121.92))" 
sortexpr = search.SortExpression(
    expression=loc_expr, 
    direction=search.SortExpression.ASCENDING, default_value=4501) 
search_query = search.Query(
    query_string=query, 
    options=search.QueryOptions(
    sort_options=search.SortOptions(expressions=[sortexpr]))) 

results = index.search(search_query) 
print results 

而且回報:

search.SearchResults(number_found=0L) 

我錯過了什麼或做錯了什麼?這應該返回至少那一個結果,對吧?

**更新**

做一些撬/搜索/測試後,我想這可能是關於谷歌的App Engine開發服務器的錯誤。

如果我在生產環境中的相同數據上運行位置搜索,我會得到預期的結果。當我比較並在開發環境中對數據運行完全相同的查詢時,我得到意外的0結果。

如果有人對此有任何意見,請指教。否則,對於那些遇到同樣問題的人,我在應用引擎的問題跟蹤器 here上創建了一個問題。

+0

什麼呢'打印results'打印到底是什麼? – Awalias 2013-03-25 13:41:51

+0

它在那裏:'search.SearchResults(number_found = 0L)' – kevin 2013-03-25 13:43:22

+0

這裏是我的帖子了:http://stackoverflow.com/questions/15616200/why-is-geosearching-location-based-searches-returning-zero-結果 – user1791567 2013-03-26 12:56:39

回答

4

您可能已經知道了這一點,但萬一有人遇到這篇文章,AppEngine Search API的地理搜索功能會在開發服務器上返回零結果。從https://developers.google.com/appengine/training/fts_intro/lesson2

「......一些搜索查詢不完全支持(本地運行)的開發Web服務器上,所以你需要使用部署的應用程序來運行它們」

這裏的另一個有用的鏈接: https://developers.google.com/appengine/docs/python/search/devserver