4 * StatusNet - the distributed open-source microblogging tool
5 * Copyright (C) 2009, StatusNet, Inc.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
23 $longoptions = array('base=', 'network');
25 $helptext = <<<END_OF_TRIM_HELP
26 Generates sphinx.conf file based on StatusNet configuration.
27 --base Base dir to Sphinx install
29 --network Use status_network global config table
30 (non-functional at present)
35 require_once INSTALLDIR . '/scripts/commandline.inc';
36 require dirname(__FILE__) . '/sphinx-utils.php';
39 $timestamp = date('r');
42 # Sphinx configuration for StatusNet
43 # Generated {$timestamp}
48 sphinx_iterate_sites('sphinx_site_template');
60 log = {$base}/log/searchd.log
61 query_log = {$base}/log/query.log
64 pid_file = {$base}/log/searchd.pid
74 * Build config entries for a single site
75 * @fixme we only seem to have master DB currently available...
77 function sphinx_site_template($sn)
82 'SELECT id, UNIX_TIMESTAMP(created) as created_ts, nickname, fullname, location, bio, homepage FROM profile',
83 'SELECT * FROM profile where id = $id') .
86 'SELECT id, UNIX_TIMESTAMP(created) as created_ts, content FROM notice',
87 'SELECT * FROM notice where notice.id = $id AND notice.is_local != -2');
90 function sphinx_template($sn, $table, $query, $query_info)
92 $base = sphinx_base();
93 $dbtype = common_config('db', 'type');
100 source {$sn->dbname}_src_{$table}
103 sql_host = {$sn->dbhost}
104 sql_user = {$sn->dbuser}
105 sql_pass = {$sn->dbpass}
106 sql_db = {$sn->dbname}
107 sql_query_pre = SET NAMES utf8;
109 sql_query_info = {$query_info}
110 sql_attr_timestamp = created_ts
113 index {$sn->dbname}_{$table}
115 source = {$sn->dbname}_src_{$table}
116 path = {$base}/data/{$sn->dbname}_{$table}