Thursday, May 15, 2008

Ultrasphinx setup

It was more straightforward to figure it out than other things I have done in the past. But I just write the whole thing I did to set up Ultrasphinx.

1. Sphinx installation

$ wget

$ tar xvfzp sphinx-0.9.8-rc2.tar.gz

$ cd sphinx-0.9.8-rc2/

$ ./configure --prefix=/usr/local

$ make

$ sudo make install

2. Install Chronic
(Chronic is a natural language date/time parser written
in pure Ruby.)

$ sudo gem install chronic

3. Install Ultrasphinx plugin


$ svn export svn://
(if GIT or other version control system is used.)

(Or if Subversion is used,
$ script/plugin install -x svn://

$ cp RAILS_ROOT/examples/default.base RAILS_ROOT/config/ultrasphinx/

Add is_indexed to the model: e.g.

class Overview
is_indexed :fields => [ 'title', 'description' ]
4. Build index

$ rake ultrasphinx:configure <= Generates development.conf

($ rake ultrasphinx:configure RAILS_ENV="test" <= Generates test.conf)

$ sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
(Because "rake ultrasphinx:index" has an incorrect path "/usr/local/mysql/lib/mysql".
Otherwise, "rake ultrasphinx:index" fails.)

$ rake ultrasphinx:index <= For development database

($ rake ultrasphinx:index RAILS_ENV="test" <= For test database)
(Of course, in the Test::Unit or RSpec, test database is cleaned up every time so this has to be put inside Test or Spec.
system("cd #{RAILS_ROOT}; rake ultrasphinx:index RAILS_ENV=\"test\"") )

5. Start/Stop daemon

$ rake ultrasphinx:daemon:start <= For development database

($ rake ultrasphinx:daemon:start RAILS_ENV="test" <= For test database)

- How to stop Ultrasphinx

$ rake ultrasphinx:daemon:stop

1 comment:

Tadatoshi said...


1. Now Sphinx 0.9.8 is available.

$ wget

$ tar xvfzp sphinx-0.9.8.tar.gz

$ cd sphinx-0.9.8/

And continue as before...

3. Now Ultrasphinx plugin is in GitHub. ( So,

$ cd RAILS_ROOT/vendor/plugins/

$ git clone git://