1

I am using Python2.7, Google App Engine 1.9.* and Search API. I store location-enabled points of interest. Now I want to implement GET that returns all points of interest within certain proximity from a given location.

Examples that I found in Google Search API Basics online document refer to sorting of the query results. This same example can be found as complete source package at github repo appengine-search-python-java. Whatever the query string is, the found points of interest (Stores in the example) are listed in the proximity order, nearest first.

There are also examples as to how to limit returned values by certain number of items. More Complex Search API Queries tutorial, section Query Options

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

However my use case requires cut-off to be a distance, not a hard number of items. Does anyone have an example of that?

Michael
  • 1,851
  • 4
  • 19
  • 26

1 Answers1

2

Oops, did not read closely enough, the answer is in the same place 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:
  # ...
Michael
  • 1,851
  • 4
  • 19
  • 26