from google.appengine.api import search listingLocation = 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 code query_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 results except search.Error: logging.exception('...and this one too')
Demonstrate your proficiency to design, build and manage solutions on Google Cloud Platform.