While building this blog engine, I knew I wanted good search capabilities. I had heard good things about sphinx, so I decided to give it a try and see what was available for integration with Rails.

I tried getting started with this article. I quickly ran into problems with the installation instructions, in particular, this line:

   1  ruby script/plugin install svn://rubyforge.org/var/svn/fauna/ultrasphinx/trunk

The problem is that URL no longer works (or at least wasn’t working on 7/19/2008). The purpose of this post is to describe what I had to do to work around this issue.

Most of the posts I have seen on ultrasphinx strongly advocate installing it as a plugin, though I believe I found one that recommended installing it as a gem. Since the URL didn’t work, I had no choice but to install as a gem. The gem installation went fine. I used the following command:

   1  sudo gem install ultrasphinx

After a few hours of futzing around with making my Rails app load the gem correctly, I revisited the plugin idea. What ultimately worked for me was to copy some files from the gem installation into my plugins folder.

First, create the folder for the ultrasphinx plugin:

   1  mkdir vendor/plugins/ultrasphinx

Next, you need to find where your ultrasphinx gem was installed. My was located at /usr/local/lib/ruby/gems/1.8/gems/ultrasphinx-1.11/

Copy the necessary files from that location to the ultrasphinx folder you previously created.

   1  cp /usr/local/lib/ruby/gems/1.8/gems/ultrasphinx-1.11/init.rb path/to/your/project/vendor/plugins/ultrasphinx
   2  cp -r /usr/local/lib/ruby/gems/1.8/gems/ultrasphinx-1.11/lib path/to/your/project/vendor/plugins/ultrasphinx  

Your app now has the ultrasphinx plugin installed. I hope you found this helpful. Happy searching!