Upgrading Thinking Sphinx
Thinking Sphinx has changed quite a bit over time, and if you’re upgrading from an old version, you may find some of your code needs to be changed as well. Here’s a few tips…
Checking the version number
In later versions of Thinking Sphinx, there is a rake task available to check your version:
rake thinking_sphinx:version
If you’re using an older version of Thinking Sphinx as a gem, then just look at the gem version number. If you’ve got it installed as a plugin, though, then you’re going to have to have a look at vendor/plugins/thinking_sphinx/lib/thinking_sphinx.rb, as that’s where the version number was stored.
Upgrading from 1.3.2 or earlier (when using Sphinx 0.9.9)
If you’ve been using the sphinx-0.9.9 branch from GitHub or the thinking-sphinx-099 gem, there is now just one version of Thinking Sphinx that works for both versions. The installation page provides a good overview of the new setup.
The quick version for gem users is two-fold, once you’ve installed the thinking-sphinx gem. First, change your gem setup in environment.rb:
config.gem(
'thinking-sphinx',
:lib => 'thinking_sphinx/0.9.9',
:version => '1.3.3'
)
And then, change your Rakefile to have two require lines instead of one:
require 'thinking_sphinx/0.9.9'
require 'thinking_sphinx/tasks'
If you’re using Thinking Sphinx as a plugin, then when you update, all you’ll need to do is add a require statement to the end of your environment.rb file:
require 'thinking_sphinx/0.9.9'
Upgrading from 1.2.13 or earlier
With the advent of Thinking Sphinx 1.3.0, the delayed and datetime delta approaches are now in separate gems. Also, Delayed Job is no longer vendored in Thinking Sphinx, so you may need to install it as a plugin as well.
The delta page has been updated to reflect these changes, so have a read through that to figure out how to make sure your application will still work.
If you’re not using deltas, or only using the default delta approach, then this change does not affect you.
Upgrading from 1.1.17 or earlier
In versions of Thinking Sphinx before 1.1.18, the morphology/stemmer defaulted to stem_en (English). Obviously, not every website uses the English language, so this setting has been removed, with no stemmer as the default.
If you would like to keep stem_en as your stemmer, you’ll need to add it to your config/sphinx.yml file:
development:
morphology: stem_en
test:
morphology: stem_en
production:
morphology: stem_en
To get a better understanding of stemmers, I recommend reading Sphinx’s documentation.