The title is not clear so let me explain:
In my apps, I have events. They are geolocated: I store the latitude and longitude.
My problem is that, when users search for events, they type things like: kansas, montreal etc.
So when I locate kansas (using geocoder), I get its “center”, and so when I ask sunspot for the events “near” this location, I only get the ones close to the center of the location. It’s even worse if they type france or australia.
I was wondering if you knew about a good way to handle that.
My only idea right now is to also store the country, state etc of the location of the event when it’s saved (I can get the normalized address from google), and then do a text search of what they entered in the location field…
But there is problem about that approach 🙁
In solr, it’s impossible to do the following:
any_of do
with(:coordinates).near(coord[0], coord[1], :precision => 3)
keywords where
end
because near can’t be nested. See here.
Did they make changes in sunspot 1.3 to allow that?
Do you see any other solution? I might even accept changing from solr to another search platform like elastic search but I would prefer not to.
I switched to ElasticSearch, and I absolutely love it. It’s so much better for geolocation search… I still have some problems with facets, but overall I would recommend ES over sunspot for someone starting a new app.