Skip to content

How to setup the search engine

imustardsoft edited this page Jun 14, 2012 · 10 revisions

SocialStream supports the use of Sphinx as a search engine.

Instaling sphinx in UNIX

You must install the Sphinx packet for UNIX:

sudo apt-get install sphinxsearch

In order to work without any problem make sure NOT to set START=yes in /etc/default/sphinxsearch. It should be START=no.

Installing Sphinx gem "thinking-sphinx" in SocialStream

This gem is installed by default when doing bundle update as it's included in social_stream gemspec.

First time running Sphinx

The first time you want to use Sphinx you should rebuild all the index for you models for Sphinx to use them. This is achieved by typing rake ts:rebuild.

If the server doesn't init just type rake ts:start.

Using rake tasks

Indexing elements

Use rake ts:in to begin the indexation.

Rebuilding index structure

Use rake ts:rebuild if you have changed or added the define_index method for any of the models. This rebuilds everything. If you just need to index new elements use rake ts:in.

Starting/Stopping Sphinx server

Use rake ts:start and rake ts:stop to start and stop the sphinx server.

Deploying with capistrano

You may want to rebuild the indexes every time your application is deployed, so changes in your code reach the index structure. Add this to your config/deploy.rb

before 'deploy:restart', 'deploy:rebuild_sphinx'

namespace :deploy do
  task :rebuild_sphinx do
    run "cd #{ release_path } && bundle exec \\"rake ts:rebuild RAILS_ENV=production\\""
  end
end

Quick setup Sphinx on Ubuntu

1,sudo apt-get install sphinxsearch

2,rake thinking_sphinx:index or rake ts:index or rake ts:in

3, rake thinking_sphinx:configure or rake ts:conf or rake ts:config

4, rake thinking_sphinx:start or rake ts:start

5,rake thinking_sphinx:stop or rake ts:stop(if you want to stop)

Setting up the cron job to index new items

TODO

Sphinx settings

These settings are located in config/sphinx.yml, copied by social_stream install generator. TODO

Clone this wiki locally