user1791567
user1791567

Reputation: 1428

Google App Engine - Searching for Locations within a Specified Distance returning Zero results

Searching geolocations by distance using GAE Search API (1.7.6) returns zero results always...

I build the following query: distance(geoLocation, geopoint(27.241131, -82.464445)) < 16093 /* 10 Miles in meters */

Results are always zero although I have geopoints within the distance. For instance my search origin is in this case lat: 27.241131, lgn: -82.464445 and one of the geopoints within the range is lat:27.233247, lng-82.48819800000001.

When I calculate the distance using google maps api v3 like this:

  google.maps.geometry.spherical.computeDistanceBetween (
new google.maps.LatLng(27.241131, -82.464445), 
new google.maps.LatLng(27.233247, -82.48819800000001)) = 2509.46

This is how I store geopoints along with other fields

dictFields = []

dictFields.append(search.AtomField(name = 'zipcode', value = k.get('zipcode')))

geopoint = search.GeoPoint(float(lat), float(lng))
dictFields.append(search.GeoField(name = 'geoLocation', value = geopoint))

Later I do

search.Document(doc_id = document_id, fields = dictFields)

What is wrong here? I know that Search works because it returns results when I search by other fields different than geopoints.

Search id done like this:

options = search.QueryOptions(limit=1000, returned_fields=['geoLocation', 'zipcode'])
query = search.Query(query_string=query_str, options=options)

where query_str = distance(geoLocation, geopoint(27.241131, -82.464445)) < 16093

Update

I'm testing using the geopoint stored by the index and get search.SearchResults(number_found=0L). Question: Is this suppose to work in the dev environment?

Help is appreciated!!!!!

Upvotes: 2

Views: 702

Answers (1)

flynn
flynn

Reputation: 1584

I have an open issue on this too - I did some prying and it looks like a problem with the development environment. It works in the production environment.

See issue if you want to follow: Why is geosearching/location based searches returning zero results?

You'll also find a link to an issue tracker I posed.

Upvotes: 1

Related Questions