Skip to content

Sphinx Fulltext Search

spuds edited this page Feb 16, 2015 · 1 revision

[SETUP](Setup Home) > SPHINX SEARCH

Sphinx Fulltext Search

Sphinx fulltext search provides a way to use Sphinx Open Source Search Server for ElkArte search. Using Sphinx will improve the performance of searching as well as indexing particularly in boards with large databases.

Installing

To use Sphinx with ElkArte you must first install the search daemon on your server. For help in doing this go to the Sphinx site http://sphinxsearch.com/docs/current.html#installation as this will vary depending on the OS and version that you are using.

Sphinx Configuration

An initial Sphinx configuration file (sphinx.conf) can be generated through the ACP and then copied to the sphinx.conf for your installation.

  • Config directory which will have sphinx.conf and stopwords.txt (If defined).
    • For example on Ubuntu 14.04 this is typically /etc/sphinxsearch
  • Data directory which will have index files. For example
    • For example on Ubuntu 14.04 this is typically /var/sphinxsearch/data
  • A Log directory which will save all logs related to sphinx search server.
    • For example on Ubuntu 14.04 this is typically /var/logs/sphinxsearch

To generate the config, go to Admin -> Forum -> Search -> Configure Sphinx

  • Enter the correct directory's (as above) for your installation, the remainder of the settings can normally be left as default. Follow these steps.
  • Select "Save"
  • Select "Create Sphinx Config"
  • Copy the resulting file to your servers sphinx.conf file
  • Restart sphinx so it uses the new config, e.g. service sphinxsearch restart
  • Return to your ACP and select "Test Connection to Sphinx daemon"
    • If you don't get a success result, then there is a problem with the directories, or specified ports, you need to fix this as its not an ElkArte issue.

Search Method

Next we need to tell ElkArte to use Sphinx as the search method. Go to Admin -> Forum -> Search -> Search Method. There are currently two interfaces available, SphinxQL or Sphinx (API), select the one you want to use. To use SphinxAPI you will need to copy the sphinxapi.php, that is included with with Sphinx, to the root of your forum. However it is recommend you to use SphinxQL instead of the API. To learn more about the two read http://sphinxsearch.com/blog/2013/07/23/from-api-to-sphinxql-and-back-again/

Create Indexes

Once you have validated that ElkArte can successfully connect to the search daemon then its time to create your initial indexes. The configuration file defines two indexes:

  • elkarte_delta_index : This is an index that only stores recent changes and can be called frequently. i.e. every hour or 30 minutes
  • elkarte_base_index : This is an index that stores the full database and should be called less frequently, i.e. once a day

As an example, to create your initial indexes on Ubuntu, you would enter the following commands in a terminal window.

  • /usr/bin/indexer --config /etc/sphinxsearch/sphinx.conf --rotate elkarte_base_index
  • /usr/bin/indexer --config /etc/sphinxsearch/sphinx.conf --rotate elkarte_delta_index

Add cron jobs

In order to keep Sphinx up to date, you must use a cron job to update the indexes, otherwise new or deleted content will not be reflected in the search results

  • Run the full index once a day at 3am
    • 0 3 * * * /usr/bin/indexer --config /etc/sphinxsearch/sphinx.conf --rotate elkarte_base_index
  • Run the delta index every 30 minutes
    • */30 * * * * /usr/bin/indexer --config /etc/sphinxsearch/sphinx.conf --rotate elkarte_delta_index
Clone this wiki locally