from google.appengine.api import searchlistingLocation = search.GeoPoint(37.78, -122.39)listing = search.Document( fields=[ search.TextField(name='description', value='Great condo in the city'), search.NumberField(name='bedrooms', value=2), search.GeoField(name='location', value=listingLocation) # omitting the other fields for this example ])
put()
try: index = search.Index(name='listingsForSale') index.put(listing)except search.Error: logging.exception('Make sure you handle this error')
index = search.Index(name='listingsForSale')# search for listings within 8050 meters (~5 miles) of the 94109 zip codequery_string = 'distance(location, geopoint(37.7929, -122.4212)) < 8050'
try: results = index.search(query_string) # Iterate over the documents in the results for scored_document in results: pass # handle resultsexcept search.Error: logging.exception('...and this one too')
Use promo code NEXT1720 to save $300 off general admission
No comments :
Post a Comment