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
76 * Build config entries for a single site
77 * @fixme we only seem to have master DB currently available...
79 function sphinx_site_template($sn)
84 'SELECT id, UNIX_TIMESTAMP(created) as created_ts, nickname, fullname, location, bio, homepage FROM profile',
85 'SELECT * FROM profile where id = $id') .
88 'SELECT id, UNIX_TIMESTAMP(created) as created_ts, content FROM notice',
89 'SELECT * FROM notice where notice.id = $id AND notice.is_local != -2');
92 function sphinx_template($sn, $table, $query, $query_info)
94 $base = sphinx_base();
95 $dbtype = common_config('db', 'type');
102 source {$sn->dbname}_src_{$table}
105 sql_host = {$sn->dbhost}
106 sql_user = {$sn->dbuser}
107 sql_pass = {$sn->dbpass}
108 sql_db = {$sn->dbname}
109 sql_query_pre = SET NAMES utf8;
111 sql_query_info = {$query_info}
112 sql_attr_timestamp = created_ts
115 index {$sn->dbname}_{$table}
117 source = {$sn->dbname}_src_{$table}
118 path = {$base}/data/{$sn->dbname}_{$table}