I'm new to using the Sunspot gem. I have it installed and correctly indexing and querying. However, I am now trying to bound the search parameters by including geo search. My database table that is indexed by SOLR has latitude and longitude fields but I'm unable to get geo-search working.
Here's what I have in my model:
searchable do
.
.
.
double :latitude, :as => "lat"
double :longitude, :as => "lon"
location (:location) { Sunspot::Util::Coordinates.new(lat, lon) }
end
However when I run the rake task to reindex it fails with the following:
undefined method `lat' for #<Product:0x1076e6650>
I've also tried:
latlon(:location){ Sunspot::Util::Coordinates.new(lat, lon) }
and
location(:location){ Sunspot::Util::Coordinates.new(:latitude, :longitude) }
I've tried various different options such as passing in :latitude and :longitude rather than lat, lon but I seem to be running into different errors each time.
I've got the following gems installed: sunspot (2.0.0, 1.3.3, 1.2.1) sunspot_rails (1.3.3, 1.2.1) sunspot_solr (2.0.0)
Any suggestions would be greatly appreciated! Thanks in advance.