Sunspot geospatial search ERROR:unknown field 'location_ll'

99封情书 提交于 2019-12-07 17:14:14

问题


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!


回答1:


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




回答2:


If you're using websolr you'll need to make sure you set your index type to Sunspot 2.0 for Ruby on Rails (Solr 3). Mine was defaulted to Sunspot 1.3.x for Ruby on Rails, and this was causing the unknown field 'location_ll' error.

I'm using the Heroku addon, and for that you can set the index type by running:

$ heroku addons:open websolr 

Then clicking on your index (probably default), and selecting from the drop down and hitting change:




回答3:


Also make sure that schema.xml is loaded from your solr directory, not from default's gem's directory.



来源:https://stackoverflow.com/questions/10909281/sunspot-geospatial-search-errorunknown-field-location-ll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!