From 525b86771866f368a4df9163562fbfe43be76b40 Mon Sep 17 00:00:00 2001 From: millette Date: Sun, 23 Nov 2008 21:30:36 -0500 Subject: [PATCH] sphinx documentation and sample config file darcs-hash:20081124023036-099f7-d2c32538e8a81170032ba0bc9fc5caf79e2b59a9.gz --- README | 33 ++++++++++++++++++++- config.php.sample | 2 +- sphinx.conf.sample | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 sphinx.conf.sample diff --git a/README b/README index 524a69e647..6163d93204 100644 --- a/README +++ b/README @@ -141,7 +141,11 @@ For some functionality, you will also need the following extensions: server to store the data in. - Mailparse. Efficient parsing of email requires this extension. Submission by email or SMS-over-email uses this extension. - +- Sphinx Search. A client for the sphinx server, an alternative + to MySQL or Postgresql fulltext search. You will also need a + Sphinx server to serve the search queries. + + You will almost definitely get 2-3 times better performance from your site if you install a PHP bytecode cache/accelerator. Some well-known examples are: eaccelerator, Turck mmcache, xcache, apc. Zend Optimizer @@ -590,6 +594,22 @@ backups of a working Laconica system by backing up the database and the Web directory. To backup the database use mysqldump (http://ur1.ca/7xo) and to backup the Web directory, try tar. +Sphinx +------ + +To use a Sphinx server to search users and notices, you also need +to install, compile and enable the sphinx pecl extension for php on the +client side, which itself depends on the sphinx development files. +"pecl install sphinx" should take care of that. Add "extension=sphinx.so" +to your php.ini and reload apache to enable it. + +You can update your MySQL or Postgresql databases to drop their fulltext +search indexes, since they're now provided by sphinx. + +On the sphinx server side, a script reads the main database and build +the keyword index. A cron job reads the database and keeps the sphinx +indexes up to date. + Upgrading ========= @@ -931,6 +951,17 @@ enabled: Set to true to enable. Default false. server: a string with the hostname of the memcached server. Can also be an array of hostnames, if you've got more than one server. +sphinx +------ + +You can get a significant boost in performance using Sphinx Search +instead of your database server to search for users and notices. +(http://sphinxsearch.com/). + +enabled: Set to true to enable. Default false. +server: a string with the hostname of the sphinx server. +port: an integer with the port number of the sphinx server. + integration ----------- diff --git a/config.php.sample b/config.php.sample index 8f195e4642..c2e7bf151a 100644 --- a/config.php.sample +++ b/config.php.sample @@ -59,7 +59,7 @@ $config['db']['database'] = 'mysql://laconica:microblog@localhost/laconica'; # sphinx search $config['sphinx']['enabled'] = false; $config['sphinx']['server'] = 'localhost'; -$config['sphinx']['PORT'] = 3312; +$config['sphinx']['port'] = 3312; # Users to populate the 'Featured' tab diff --git a/sphinx.conf.sample b/sphinx.conf.sample new file mode 100644 index 0000000000..b79adf15c0 --- /dev/null +++ b/sphinx.conf.sample @@ -0,0 +1,71 @@ +# +# Minimal Sphinx configuration sample for laconica +# + +source src1 +{ + type = mysql + sql_host = localhost + sql_user = USERNAME + sql_pass = PASSWORD + sql_db = identi_ca + sql_port = 3306 + sql_query = SELECT id, UNIX_TIMESTAMP(created) as created_ts, nickname, fullname, location, bio, homepage FROM profile + sql_query_info = SELECT * FROM profile where id = $id + sql_attr_timestamp = created_ts +} + + +source src2 +{ + type = mysql + sql_host = localhost + sql_user = USERNAME + sql_pass = PASSWORD + sql_db = identi_ca + sql_port = 3306 + sql_query = SELECT id, UNIX_TIMESTAMP(created) as created_ts, content FROM notice + sql_query_info = SELECT * FROM notice where id = $id + sql_attr_timestamp = created_ts +} + +index identica_notices +{ + source = src2 + path = DIRECTORY/data/identica_notices + docinfo = extern + charset_type = utf-8 + min_word_len = 3 + stopwords = DIRECTORY/data/stopwords-en.txt +} + + +index identica_people +{ + source = src1 + path = DIRECTORY/data/identica_people + docinfo = extern + charset_type = utf-8 + min_word_len = 3 + stopwords = DIRECTORY/data/stopwords-en.txt +} + +indexer +{ + mem_limit = 32M +} + +searchd +{ + port = 3312 + log = DIRECTORY/log/searchd.log + query_log = DIRECTORY/log/query.log + read_timeout = 5 + max_children = 30 + pid_file = DIRECTORY/log/searchd.pid + max_matches = 1000 + seamless_rotate = 1 + preopen_indexes = 0 + unlink_old = 1 +} +