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')
JOIN
GROUP BY
body = {"rows":[ {"json": {"column_name":7.7,}} ]}response = bigquery.tabledata().insertAll( projectId=PROJECT_ID, datasetId=DATASET_ID, tableId=TABLE_ID, body=body).execute()
SUM()
COUNT()
AVG()
MIN()
MAX()
FIRST_VALUE
LAST_VALUE()
COVAR_POP()
COVAR_SAMP()
STDDEV_POP()
STDDEV_SAMP()
VAR_POP()
VAR_SAMP()
SELECT CORR(a.data, b.data) corr, a.room room, count(*) cFROM ( SELECT TIME(USEC_TO_TIMESTAMP(INTEGER(Timestamp / 60000000) * 60000000)) time, AVG(DATA) data, room FROM [io_sensor_data.moscone_io13] WHERE DATE(USEC_TO_TIMESTAMP(Timestamp- 8*60*60000000)) = '2013-05-16' AND sensortype='temperature' GROUP EACH BY time, room) aJOIN EACH ( SELECT TIME(USEC_TO_TIMESTAMP(INTEGER(Timestamp / 60000000) * 60000000)) time, AVG(data) data, room FROM [io_sensor_data.moscone_io13] WHERE DATE(USEC_TO_TIMESTAMP(Timestamp- 8*60*60000000)) = '2013-05-17' AND sensortype='temperature' GROUP EACH BY time, room) b ON a.time=b.time AND a.room = b.room GROUP EACH BY roomHAVING corr IS NOT NULL AND c > 800 ORDER EACH BY corr DESC
SELECT CORR(a.data, b.data) corr, a.sensortype a_sensortype, b.sensortype b_sensortype, a.room room, count(*) cFROM ( SELECT TIME(USEC_TO_TIMESTAMP(INTEGER(Timestamp / 60000000) * 60000000)) time, AVG(DATA) data, room, sensortype FROM [io_sensor_data.moscone_io13] WHERE DATE(USEC_TO_TIMESTAMP(Timestamp- 8*60*60000000)) = '2013-05-16' AND sensortype != 'pressure' AND sensortype != 'altitude' AND room != 'None' GROUP EACH BY time, room, sensortype) aJOIN EACH ( SELECT TIME(USEC_TO_TIMESTAMP(INTEGER(Timestamp / 60000000) * 60000000)) time, AVG(data) data, room, sensortype FROM [io_sensor_data.moscone_io13] WHERE DATE(USEC_TO_TIMESTAMP(Timestamp- 8*60*60000000)) = '2013-05-16' AND sensortype != 'pressure' AND sensortype != 'altitude' AND room != 'None' GROUP EACH BY time, room, sensortype) b ON a.time=b.time AND a.room = b.room WHERE a.sensortype > b.sensortype GROUP EACH BY room, a_sensortype, b_sensortypeHAVING corr IS NOT NULL AND c > 800 ORDER EACH BY corr DESC
Use promo code NEXT1720 to save $300 off general admission