1. Sphinx support

    1. install sphinx
    2. install thinking sphinx gem

    install Sphinx on Snow Leopard

    I forgot why I had to install 0.9.9-rc2 on Snow Leopard, but I used the following and it worked:

    Get Sphinx 0.9.9-rc2 or newer. Install with:

    # wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz
    # tar xzf sphinx*.tar.gz
    # cd sphinx-0.9.9
    # LDFLAGS="-arch x86_64" ./configure --prefix=/usr/local --with-mysql=/usr/local/mysql
    # make && sudo make install
    # sudo gem install thinking-sphinx

    install Sphinx on debian

    # wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz
    # tar xzf sphinx*.tar.gz
    # cd spinx-0.9.9
    # ./configure
    # make && sudo make install
    # sudo gem install thinking-sphinx

    Getting started

    Once you have Sphinx and thinking-sphinx installed, the “sphinx” brick is automatically activated add all fulltext searches will go through Sphinx (you can change the setting in config/bricks.yml if you do not like this).

    Since you will most likely use Sphinx in production, I will use this environment in the examples.

    capistrano on debian server

    Just deploy your application and.. voilà: the sphinx search daemon will be started for you, a cron task will be added to reindex your data and you even have a worker up and running for the deltas.

    In case you run into troubles or need to execute the commands by hand, read on…

    sphinx related

    Setup:

    # rake RAILS_ENV=production sphinx:setup

    Start search daemon:

    # rake RAILS_ENV=production sphinx:start

    Stop search daemon:

    # rake RAILS_ENV=production sphinx:stop

    To index your data, you have to run:

    # rake RAILS_ENV=production sphinx:index

    You can use the setup_indexer rake task to install/update the cron job for you.

    worker (delta indexes)

    If you have installed the “delayed_job” gem, the “worker” brick is activated and delta indexes are resolved with the “delayed_job” plugin. If you should therefore start a worker to handle the delta indexes (all changes that happen between two full indexes). Something like this starts the job:

    # rake RAILS_ENV=production worker:start

    To stop the worker:

    # rake RAILS_ENV=production worker:stop

    capistrano

    When the brick is activated on your development machine, the sphinx tasks will get inserted into the deployment process, starting and stopping the search deamon as needed.

    If you have enabled sphinx in production mode on your development machine, this will automatically activate sphinx on the server. Make sure sphinx and thinking-sphinx are installed there !

    For every rake task listed above, there is an equivalent capistrano task. These tasks are:

    • sphinx_setup, sphinx_start, sphinx_stop, sphinx_setup_indexer
    • worker_start, worker_stop

    And if you want to see the details, have a look at the capistrano receipts in bricks/sphinx/deploy.rb and bricks/worker/deploy.rb and the rake tasks in bricks/sphinx/tasks.rb and bricks/worker/tasks.rb.

    Gaspard Bucher

    comments

    1. leave a comment