A couple month ago, after seven month of pre-release, sunspot-2.0 was released. It added several nice Solr 3 features including spatial search and field collapsing. Upgrading to sunspot-2.0 is pretty easy. However, you may run into a few obstacles, especcially if you are planning to use new spatial search functionality.
Updating to latest version of sunspot is easy, just run:
bundle update sunspot_rails sunspot_solr. It almost entirely backwards compatable, unless you are planning to use Solr 3 features, such as: Spatial Search or Field Grouping.
New Field Type
In my case, I wanted use Solr 3 radius search search, so I re-defined
location field of my model to be a new type of
1 2 3 4 5 6 7 8 9 10 11 12
Additionally, I changed my search routines to use new sunspot-2.0 method
in_radius for geolocation filtering:
1 2 3 4 5 6
As soon as I did it, I tried re-indexing and got the following error:
Status 400 - ERROR: [doc=JobPosting 1] unknown field 'location_ll'
I figured that I needed to delete my
/solr folder, and restart solr instance to re-generate config files. As soon as I did, it fixed the problem locally – I was able to re-index, and get all my tests to pass.
After I deployed my changes to Heroku, I got the same error:
1 2 3
Apparently, all I had to do is to re-configure my index on WebSolr. In order to do that, I logged in to WebSolr Console, clicked on the index, and selected “Sunspot 2.0 for Ruby on Rails (Solr 3)” option from “Index Type” drop down, clicked “Change”, and waited for it to re-configure. After that, I re-indexed the data set, and was able to start using new sunspot-2.0 features.