1

I'm using the PHP-GDS library to get access to the AppEngine DataStore, however this doesn't seem to support geolocation queries. I'm currently storing the latitude and longitude in separate columns.

What's the recommended way in 2015 (there are lots of suggestions from 2010) to query the DataStore with geoqueries?

Example use-cases: - Return the 10 closest rows from {Lat, Long}, sorted by distance.

Alex K
  • 8,269
  • 9
  • 39
  • 57
XCode Warrier
  • 765
  • 6
  • 20
  • 1
    In Python per https://cloud.google.com/appengine/docs/python/search/ , and Java per (same but with java instead of python), and Go per (same but with go instead), the recommended solution is the Search API. However per http://stackoverflow.com/questions/26005906/accessing-google-app-engines-search-api-from-php this doesn't seem to exist (yet) for PHP; the recommended solution is to write a module in one of the three Search-supporting languages (the rest of your app stays in PHP) and use that module for Search API access, only. – Alex Martelli Mar 09 '15 at 21:59
  • 1
    Thanks - so can I 1. Store the lat and lon in the datastore using PHP 2. Write a module that can be accessed via a url e.g. /search?lat=1.2&long=1.3 3. Return results as JSON 4. Parse JSON and present to user? – XCode Warrier Mar 09 '15 at 22:15
  • Reworded for clarity. – Alex K Mar 09 '15 at 22:54
  • @XCodeWarrier, **almost** -- the Search API works a bit differently -- not directly on the datastore! I recommend the URLs I gave above to see what exactly e.g a Python module will need to do to prepare documents for search from datastore entities. JSON back and forth is fine of course. – Alex Martelli Mar 10 '15 at 03:11
  • Datastore does not support geo queries directly. If you are going to split out the search component to Python and take advantage of the Search API, take a gander at this GitHub repo (of mine) where I do exactly that - have a Python model for accessing the search API from PHP. https://github.com/tomwalder/phpne14-text-search – Tom Mar 10 '15 at 14:50

1 Answers1

0

Datastore does not support geo-queries so I've used the Search API instead.

XCode Warrier
  • 765
  • 6
  • 20
  • I've release native Search API support for PHP - in case it's of interest! https://github.com/tomwalder/php-appengine-search – Tom Aug 27 '15 at 22:32