1. Sphinx installation
$ wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8-rc2.tar.gz
$ 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
$ cd RAILS_ROOT
$ svn export svn://rubyforge.org/var/svn/fauna/ultrasphinx
/trunk/vendor/plugins/ultrasphinx
(if GIT or other version control system is used.)
(Or if Subversion is used,
$ script/plugin install -x svn://rubyforge.org/var/svn/fauna/ultrasphinx
/trunk/vendor/plugins/ultrasphinx)
$ cp RAILS_ROOT/examples/default.base RAILS_ROOT/config/ultrasphinx/
Add is_indexed to the model: e.g.
4. Build index
class Overview
is_indexed :fields => [ 'title', 'description' ]
end
$ 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.
i.e.
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:
Update:
1. Now Sphinx 0.9.8 is available.
So,
$ wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8.tar.gz
$ tar xvfzp sphinx-0.9.8.tar.gz
$ cd sphinx-0.9.8/
And continue as before...
3. Now Ultrasphinx plugin is in GitHub. (http://github.com/fauna/ultrasphinx/tree/master) So,
$ cd RAILS_ROOT/vendor/plugins/
$ git clone git://github.com/fauna/ultrasphinx.git
Post a Comment