Another happy UltraSphinx user

10 Dec 2008

I wanted to set up searching on my military reading lists site, and while the dataset is small enough that a SQL LIKE query would have done the trick, I wanted to introduce a real search engine in the mix. Thanks to a couple of helpful posts from Neeraj Kumar and Rein Henrichs, it was simple to get the basic functionality up and running. I'm using the latest UltraSphinx code from GitHub and as far as I can tell everything is working fine with Ruby 1.8.6, Passenger 2.0.5, and Rails 2.2.2.

The only thing I would add to Rein's post is a variation on his Capistrano tasks. He uses this:

namespace :sphinx do
  desc "Generate the ThinkingSphinx configuration file"
  task :configure do
    run "cd #{release_path} && rake thinking_sphinx:configure"
  end
end
after "deploy:update_code", "sphinx:configure"

and I used this:

def run_remote_rake(rake_cmd)
  run "cd #{current_path} && /usr/local/bin/rake RAILS_ENV=production #{rake_cmd}"
end
after "deploy", "ultrasphinx:configure"

My technique is slightly shorter, but his method would allow you to run that task independently of a deploy. I reckon both ways work.