Sphinx SearchSo far, I’ve introduced Sphinx search and told you how to install Sphinx search. The next step would be to get it running. This is almost as simple as installing it, but a little bit more work. This is only a very basic configuration setup. I might at a later stage introduce you to some of the more complex settings.

To get it up and running, there are three components that you need to be aware of.

  1. The sphinx.conf configuration file which is the heart and soul of Sphinx search
  2. The indexer command which will compile the index that you will be querying
  3. The searchd command which will start the search daemon (or service) on your server

Note that by default on a Debian server, the indexer and searchd commands can be found in /usr/local/bin/ and the sphinx.conf file can be found in /usr/local/etc/

1. Editing the sphinx.conf file
You can either create a sphinx.conf file locally and then secure copy it to the /usr/local/etc/ directory on your server, or you can simply use your favorite command line editor (which should be vim :) ) on your server. There is a sample config file which you could copy and then edit, should you want to. Do it like such:

cd /usr/local/etc
cp sphinx.conf.in sphinx.conf

In the config file, there are 4 main configuration components:

  1. The source of the index. I.e. what it should index. Plainly put, which database, the query, the query settings, etc.
  2. The index settings. How should Sphinx use the source you’ve set up.
  3. The indexer settings. How should Sphinx index your previously set up indexes
  4. The searchd settings. How should Sphinx listen for queries from your application

Note that the source section of the index can be inherited, so you don’t have to repeat settings all the time. Also note that you may well want more than one index to query (lets say you want an index for blog posts and for bookmarks) so for every index you need, you’ll create a source and index. This is then in VERY basic terms what your structure of the config file should look like:

#The settings and SQL source for your index
source blogposts
{
    #SQL and settings goes here
}
#The index for the source
index blogpostsindex
{
    #the source of this index
    #and its settings goes here
    source = blogposts
}

indexer
{
    #settings for the indexer command
}

searchd
{
    #settings for the sphinx daemon goes here
}

Lets move on to a practical example. Setting up Sphinx Search Part 2

Welcome back! You should subscribe to my RSS feed here.
You should follow me on Twitter here
You should follow me on Gatorpeeps here.