2

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!!!!!

user1791567
  • 1,388
  • 1
  • 16
  • 29

1 Answers1

1

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.

Community
  • 1
  • 1
flynn
  • 1,572
  • 2
  • 12
  • 26
  • thanks for your reply. If you say you tested it and works in prod that's what I need to know and I will go with your answer. Also I noticed that when you do a search (just because you are testing your logic) and have no documents indexed a weird exception gets thrown, something related to a matched_count = 0. Then if you go to the SDK console and click the Fulltext index tab it will brake with a nasty exception. – user1791567 Mar 26 '13 at 12:55
  • odd behavior indeed. let me know if you see different in the production environment. Odd behavior indeed. A little discouraged by the lack of testing as these are some pretty obvious bugs. To get to your full text search in the dev environment, you can just paste localhost:admin_port#/search/index?index=YOUR INDEX NAME HERE&query=&namespace= That's a workaround I guess until that link landing page is fixed. – flynn Mar 26 '13 at 14:26
  • Glad it works in prod. The only weird thing I've noticed is that I'm getting more results that I expect. So I want to find some locations within 5 'miles'.. so I convert 5 miles to meters and I have 8047m. And when I look at the result.. I don't know.. you can tell that there is no way that many of the returned markers are within 5 miles from the center point... you know what I mean? Am I doing something wrong with the conversion? – user1791567 Apr 07 '13 at 04:46
  • That's interesting - you're conversion looks okay... try debugging by logging the distances of each result and play around with the range - start at 1 mile and go up from there. I haven't seen that in my results, but let me know how things look when you debug. Make sure the center point is the actual center point being used in the query – flynn Apr 07 '13 at 14:21
  • Thanks @kevin. I checked all that and seems like I'm doing the right thing. I decided to go with 5000 = 5 miles. Thanks a lot. – user1791567 Apr 15 '13 at 01:57