active_record_sunspotter

Upgrade notes

Upgrading the sunspot family of gems from 2.0.0 to 2.1.0 has been a bit of a nightmare.

However

Both solr/conf/schema.xml and solr/conf/solrconfig.xml differ between the 2 versions, so update your app’s.

Once updated, the mods in active_record_sunspotter.rb can be removed. Also, remove the added require line in the Rakefile for sunspot rake tasks.

Create a solr/solr.xml to look like so …

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false">
 <cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:}">
   <core name="production"  instanceDir="." dataDir="data/production"/>
   <core name="development" instanceDir="." dataDir="data/development"/>
   <core name="test"        instanceDir="." dataDir="data/test"/>
 </cores>
</solr>

… or use the new one, but reorganize the solr directory.

config/sunspot.yml needs an absolute solr_home for each environment, and a path too

solr_home: /Users/jakewendt/github_repo/jakewendt/active_record_sunspotter/solr
path: /solr/production

Apparently, solr.xml’s dataDir and sunspot.yml’s path must match. Or not?

Rather confused on this issue. The command (ps | grep solr) shows a solr.data.dir of /solr/data/development even though

solr.xml ...
   <core name="development" instanceDir="." dataDir="development/data"/>

sunspot.yml
   path: /solr/development

Seems to use both data/development and development/data for some reason?

REALLY NEED TO MAKE THIS UPGRADABLE! Not Upgrade-and-start-overable!

sudo mkdir /opt/local/lib/ruby2.0/gems/2.0.0/gems/sunspot_solr-2.1.0/solr/solr-webapp sudo chmod 777 /opt/local/lib/ruby2.0/gems/2.0.0/gems/sunspot_solr-2.1.0/solr/solr-webapp

2014-05-02 14:26:28.072:INFO:oejd.DeploymentManager:Deployable added: /opt/local/lib/ruby2.0/gems/2.0.0/gems/sunspot_solr-2.1.0/solr/contexts/solr.xml 2014-05-02 14:26:28.116:WARN:oejx.XmlConfiguration:Config error at <Set name=“tempDirectory”><Property name=“jetty.home” default=“.”/>/solr-webapp</Set> java.lang.reflect.InvocationTargetException

Caused by: java.lang.IllegalArgumentException: Bad temp directory: /opt/local/lib/ruby2.0/gems/2.0.0/gems/sunspot_solr-2.1.0/solr/solr-webapp

I suppose it could be another folder, but you’d need to modify the gem’s solr/contexts/solr.xml file.

In 2.1.1, the tempDirectory is removed so this last mod is unnecessary.

Modifications

I’m stuck using version 2.0.0. Seems to be issues with java. Anywho. This file loads too early for me to override, so…

Need to edit …

/opt/local/lib/ruby2.0/gems/2.0.0/gems/sunspot_rails-2.0.0/lib/sunspot_rails.rb

… to require ‘json’ rather than ‘to_json’ for rails 4.1.0 and above like so.

if ::Rails.version >= ‘4.1’ require ‘active_support/core_ext/object/json’ elsif ::Rails.version >= ‘3’ require ‘active_support/core_ext/object/to_json’ end

The 2.1.0 version of this file is now included in this gem.

And another mod… (I may be able to patch this one.)

sunspot_rails-2.0.0/lib/sunspot/rails/searchable.rb

Must comment out the :include option.

251 find_in_batch_options = { 252 # :include => options, 253 :batch_size => options, 254 :start => options 255 }

Don’t know why now as it has been there for a while, but even looking back to 4.0.3 it hasn’t been a valid key?

ArgumentError: Unknown key: :include. Valid keys are: :start, :batch_size /my/ruby/gems/2.0/gems/activesupport-4.1.0/lib/active_support/core_ext/hash/keys.rb:71:in ‘block in assert_valid_keys’ /my/ruby/gems/2.0/gems/activesupport-4.1.0/lib/active_support/core_ext/hash/keys.rb:69:in ‘each_key’ /my/ruby/gems/2.0/gems/activesupport-4.1.0/lib/active_support/core_ext/hash/keys.rb:69:in ‘assert_valid_keys’ /my/ruby/gems/2.0/gems/activerecord-4.1.0/lib/active_record/relation/batches.rb:100:in ‘find_in_batches’ /my/ruby/gems/2.0/gems/activerecord-4.1.0/lib/active_record/querying.rb:9:in ‘find_in_batches’ /my/ruby/gems/2.0/gems/sunspot_rails-2.0.0/lib/sunspot/rails/searchable.rb:259:in ‘solr_index’

Testing

sudo /opt/local/share/mariadb/support-files/mysql.server start

c ; bundle exec rake sunspot:solr:stop ; bundle exec rake sunspot:solr:stop RAILS_ENV=test ; bundle exec rake sunspot:solr:start ; bundle exec rake sunspot:solr:start RAILS_ENV=test ; bundle exec rake test

bundle exec rake sunspot:solr:stop ; bundle exec rake sunspot:solr:start

bundle exec rake sunspot:solr:stop RAILS_ENV=test ; bundle exec rake sunspot:solr:start RAILS_ENV=test ; bundle exec rake test  ; bundle exec rake sunspot:solr:stop RAILS_ENV=test

Gemified with Jeweler

vi Rakefile
rake version:write

rake version:bump:patch
rake version:bump:minor
rake version:bump:major

rake gemspec

rake install
rake release

Copyright © 2010 [Jake Wendt], released under the MIT license