Support/Sphinx Installation

From MozillaWiki
Jump to: navigation, search

Out of Date

This document is woefully out of date. New docs are coming, but will probably be in git.

Installing Sphinx Search

The differences between installing Sphinx on a local machine or SUMO's production .

  1. Download the source from http://sphinxsearch.com/downloads.html. SUMO is using 0.9.9-release.
  2. Read the installation instructions, focusing on steps 2.1 through 2.3 (or 2.4 if installing on Windows). Make sure your system meets the requirements in steps 2.1 and 2.2.
  3. Follow the instructions in 2.3 to build and install Sphinx
    1. (optional): Set the --prefix option to /usr/local/sphinx. The binaries should end up in /usr/local/sphinx/bin, and the /usr/local/sphinx/etc should contain the configuration files. This step is optional--just insure you adjust file paths in the remainder of the directions and modify the configuration files accordingly (sphinx.conf in step 6 and search.conf.php in step 12) if you don't install using this prefix.
  4. Make sure that the folder /usr/local/sphinx/bin is in the search path.
  5. Create the directory /usr/local/sphinx/index/. This folder and files in it must be writable/readable by the apache web server user, and be on a reasonably large volume (space considerations).
  6. Replace /usr/local/sphinx/etc/sphinx.conf with the sphinx.conf from bug 463708. If /usr/local/sphinx/index/ is located in a different directory than the one used here, you'll need to update sphinx.conf.
  7. Apply the patch in bug 494327 to /usr/local/sphinx/etc/sphinx.conf. Instructions can be found in the bug
  8. Place stopwords.txt from bug 463708 in /usr/local/sphinx/index. Make sure permissions follow the directory it is in.
  9. Execute the search daemon /usr/local/sphinx/bin/searchd.
    1. (optional): Configure the search daemon to start on startup automatically. This is a good idea since searchd needs to be running for any search function to work.
  10. Execute the MySQL update file from bug 463708 on your SUMO database.
  11. Execute the MySQL update file from bug 470550 to change `se_words` into a real table from a memory table.
  12. Edit the options in search.conf.php.dist in the /trunk/scripts/ folder to fit your specific install and save it as search.conf.php in the same folder.

Indexing Sphinx Search

Initial Indexing Instructions

Indexing SUMO with Sphinx for the first time requires a bit of special care. The original draft of these directions can be found in attachment 360993 in bug 460213.

  1. Deploy all scripts/sphinx/<filename>.dist (stopwords.txt.dist, weight_weights.txt.dist, etc.) to scripts/sphinx/<filename> and set read/writable by apache
  2. On each of the webheads where sphinx is running, modify the line /etc/sphinx.conf:51 that reads "stopwords = /usr/local/sphinx/index/stopwords.txt" and replace it with "stopwords = <path to svn co>/scripts/sphinx/stopwords.txt". Do the same for /etc/sphinx.conf:98.
  3. On each of the webheads where sphinx is running, delete lastindexingtime.txt and lastindexingtime-f.txt
  4. On each of the webheads where sphinx is running, stop searchd: /usr/bin/searchd --stop
  5. On each of the webheads where sphinx is running, delete all the files in /usr/local/sphinx/index
  6. On each of the webheads where sphinx is running, in webroot, run "php manual_index.php"
  7. On each of the webheads where sphinx is running, in webroot, run "php manual_index_forums.php"
  8. On each of the webheads where sphinx is running, verify that lastindexingtime.txt and lastindexingtime-f.txt are created in webroot
  9. On each of the webheads where sphinx is running, run "/usr/bin/indexer --all"
  10. On each of the webheads where sphinx is running, in /usr/local/sphinx/index, do "touch documents.spl"
  11. On each of the webheads where sphinx is running, in /usr/local/sphinx/index, do "touch forums.spl"
  12. On each of the webheads where sphinx is running, start sphinx searchd: /usr/bin/searchd

Future Indexing Instructions

The original draft of these directions can be found in attachment 360993 in bug 460213.

  1. On each of the webheads where sphinx is running, in webroot, run "php manual_index.php"
  2. On each of the webheads where sphinx is running, in webroot, run "php manual_index_forums.php"
  3. On each of the webheads where sphinx is running, run "/usr/bin/indexer --all --rotate"

Common Errors

XML parse error: undefined entity

This XML error appears while running indexer --all in the form of "ERROR: index '<index name>': source '<source name>': XML parse error: undefined entity". This error occurs when malformed XML is outputted by /scripts/sphinx/indexer.php (or its forum-specific alternative).

XML parse error: no element found

This XML error appears while running indexer --all in the form of "ERROR: index '<index name>': source '<source name>': XML parse error: no element found". This occurs when the closing '<sphinx:docset>' tag is missing from the XML documented outputted by /scripts/sphinx/indexer.php (or its forum-specific alternative). The cause of this can be any sort of fatal error that prevents the script from finishing.