Extension:SphinxSearch

''' NOTE: this is a work in progress. Please keep your eyes on this page if you are interested. Feel free to contact the author with any questions and status updates. '''

Step 1
Download Sphinx Search Engine. Follow the installation instructions.

Step 2
Create a sphinx.conf file in some directory (let's call it $SPHINX) with the following content: source src1 { type              = mysql strip_html       = 0 index_html_attrs =

sql_host         = localhost sql_user         = root sql_pass         = ***** sql_db           = wiki sql_port         = 3306 sql_sock         = /var/lib/mysql/mysql.sock

sql_query_pre    = sql_query        = SELECT old_id,old_text,page_id FROM \ ( \                         SELECT MAX(rev_text_id) AS latest_text_id, page_id FROM wiki_page, wiki_revision \                          WHERE rev_page=page_id GROUP BY page_latest \                      ) AS latest, wiki_text WHERE old_id=latest_text_id sql_query_post   = sql_query_info   = SELECT old_text,page_id FROM \ ( \                         SELECT MAX(rev_text_id) AS latest_text_id, page_id FROM wiki_page, wiki_revision \                          WHERE rev_page=page_id GROUP BY page_latest \                      ) AS latest, wiki_text WHERE old_id=$id }

source src1stripped : src1 { strip_html      = 1 }

index wiki { source          = src1 path           = $SPHINX/wiki.sphinx docinfo        = extern morphology     = none stopwords      = min_word_len   = 1 charset_type   = utf-8 min_prefix_len = 0 min_infix_len  = 0 }

index wikistemmed : wiki {  path          = $SPHINX/wikistemmed morphology   = stem_en }

indexer {  mem_limit     = 512M }

searchd { port          = 3312 log          = /tmp/sphinx-searchd.log query_log    = /tmp/sphinx-query.log read_timeout = 5 max_children = 30 pid_file     = /tmp/sphinx-searchd.pid max_matches  = 1000 }

Make sure to adjust all values to suit your setup. Pay careful attention to the sql_ settings including the wiki databage prefix (here assumed to be wiki_) and make sure to substitute all instances of $SPHINX with whichever directory you chose above.

Note: I have to give credit where credit is due. This sphinx.conf file was in large part borrowed from this excellent article.

Step 3
Run the sphinx indexer to prepare for searching: Once again, make sure to replace $SPHINX whatever you chose above. This process is actually pretty fast, but clearly depends on how large your wiki is. Just be patient and watch the screen for updates.

Step 4
When the indexer is finished, test that sphinx searching is actually working:

Step 5
In order to speed up the searching capability for the wiki, we must run the sphinx in daemon mode. Add the following to whatever sever startup script you have access to: Note: without the daemon running, searching will not work. That is why it is critical to make sure the daemon process is started every time the server is restarted.

Step 6
Copy the Sphinx API file, sphinxapi.php to the extensions directory. This file is part of the sphinx source code, under the api/ directory.