Search code examples
ruby-on-railsruby-on-rails-3geospatialsunspot

Sunspot geospatial search ERROR:unknown field 'location_ll'


I've been trying to integrate geospatial search into my rails app for a few days now, but keep getting this error when I run rake sunspot:solr:reindex

RSolr::Error::Http - 400 Bad Request
Error: ERROR:unknown field 'location_ll'

Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><add><doc><field name=\"id\">Place 1</field><field   name=\"type\">Place</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">Place</field><field name=\"location_ll\">42.348065,-71.083623</field></doc> #etc... keeps going on for all the objects/fields being indexed in the table

As far as I can tell I'm doing everything correctly as search and indexing works when I comment out the latlon(:location) line in my model, but don't know if its a bug or if I'm missing something. Below is the setup I'm currently using:

rails 3.2.1 ruby 1.9.2p318

Gems sunspot (2.0.0.pre.120417) sunspot_rails (2.0.0.pre.120417) sunspot_solr (2.0.0.pre.120417)

:latitude and :longitude are both in float format

Place model

searchable do
text :name
latlon(:location) { Sunspot::Util::Coordinates.new(self.latitude, self.longitude) }
end

I've tried variations in the Sunspot::Util::Coordinates.new, including (lat, lon) and (latitude, longitude)

I took a look at https://github.com/sunspot/sunspot/issues/203 and as per the suggestions, stopped my sunspot server, deleted the solr folder, deleted the sunspot.yml, reinstalled, and restarted, but am still getting the error. Any ideas? Thank you very much!


Solution

  • Make sure schema.xml in the solr folder matches the latest one from here:

    https://github.com/sunspot/sunspot/blob/master/sunspot_solr/solr/solr/conf/schema.xml

    Still not working on my localhost, but it is on production