Skip to content

Commit

Permalink
Add settings for Sphinx server IP and min_word_len.
Browse files Browse the repository at this point in the history
  • Loading branch information
figvam committed Jun 28, 2010
1 parent 26b111c commit 35c2dfb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
19 changes: 15 additions & 4 deletions sphinx_plugin/includes/search/fulltext_sphinx.php
Expand Up @@ -73,11 +73,10 @@ function fulltext_sphinx(&$error)
// chdir($cwd);
}

// we only support localhost for now
$this->sphinx->SetServer('localhost', (isset($config['fulltext_sphinx_port']) && $config['fulltext_sphinx_port']) ? (int) $config['fulltext_sphinx_port'] : 3312);
// connect to localhost in case of empty IP setting
$this->sphinx->SetServer(!empty($config['fulltext_sphinx_ip']) ? $config['fulltext_sphinx_ip'] : 'localhost', !empty($config['fulltext_sphinx_port']) ? (int) $config['fulltext_sphinx_port'] : 3312);
}

$config['fulltext_sphinx_min_word_len'] = 2;
$config['fulltext_sphinx_max_word_len'] = 400;

$error = false;
Expand Down Expand Up @@ -290,7 +289,7 @@ function config_updated()
array('docinfo', 'extern'),
array('morphology', 'none'),
array('stopwords', (file_exists($config['fulltext_sphinx_config_path'] . 'sphinx_stopwords.txt') && $config['fulltext_sphinx_stopwords']) ? $config['fulltext_sphinx_config_path'] . 'sphinx_stopwords.txt' : ''),
array('min_word_len', '2'),
array('min_word_len', $config['fulltext_sphinx_min_word_len']),
array('charset_type', 'utf-8'),
array('charset_table', 'U+FF10..U+FF19->0..9, 0..9, U+FF41..U+FF5A->a..z, U+FF21..U+FF3A->a..z, A..Z->a..z, a..z, U+0149, U+017F, U+0138, U+00DF, U+00FF, U+00C0..U+00D6->U+00E0..U+00F6, U+00E0..U+00F6, U+00D8..U+00DE->U+00F8..U+00FE, U+00F8..U+00FE, U+0100->U+0101, U+0101, U+0102->U+0103, U+0103, U+0104->U+0105, U+0105, U+0106->U+0107, U+0107, U+0108->U+0109, U+0109, U+010A->U+010B, U+010B, U+010C->U+010D, U+010D, U+010E->U+010F, U+010F, U+0110->U+0111, U+0111, U+0112->U+0113, U+0113, U+0114->U+0115, U+0115, U+0116->U+0117, U+0117, U+0118->U+0119, U+0119, U+011A->U+011B, U+011B, U+011C->U+011D, U+011D, U+011E->U+011F, U+011F, U+0130->U+0131, U+0131, U+0132->U+0133, U+0133, U+0134->U+0135, U+0135, U+0136->U+0137, U+0137, U+0139->U+013A, U+013A, U+013B->U+013C, U+013C, U+013D->U+013E, U+013E, U+013F->U+0140, U+0140, U+0141->U+0142, U+0142, U+0143->U+0144, U+0144, U+0145->U+0146, U+0146, U+0147->U+0148, U+0148, U+014A->U+014B, U+014B, U+014C->U+014D, U+014D, U+014E->U+014F, U+014F, U+0150->U+0151, U+0151, U+0152->U+0153, U+0153, U+0154->U+0155, U+0155, U+0156->U+0157, U+0157, U+0158->U+0159, U+0159, U+015A->U+015B, U+015B, U+015C->U+015D, U+015D, U+015E->U+015F, U+015F, U+0160->U+0161, U+0161, U+0162->U+0163, U+0163, U+0164->U+0165, U+0165, U+0166->U+0167, U+0167, U+0168->U+0169, U+0169, U+016A->U+016B, U+016B, U+016C->U+016D, U+016D, U+016E->U+016F, U+016F, U+0170->U+0171, U+0171, U+0172->U+0173, U+0173, U+0174->U+0175, U+0175, U+0176->U+0177, U+0177, U+0178->U+00FF, U+00FF, U+0179->U+017A, U+017A, U+017B->U+017C, U+017C, U+017D->U+017E, U+017E, U+0410..U+042F->U+0430..U+044F, U+0430..U+044F, U+4E00..U+9FFF'),
array('min_prefix_len', '0'),
Expand Down Expand Up @@ -970,6 +969,8 @@ function acp()
'fulltext_sphinx_config_path' => 'string',
'fulltext_sphinx_data_path' => 'string',
'fulltext_sphinx_bin_path' => 'string',
'fulltext_sphinx_min_word_len' => 'int',
'fulltext_sphinx_ip' => 'string',
'fulltext_sphinx_port' => 'int',
'fulltext_sphinx_stopwords' => 'bool',
'fulltext_sphinx_indexer_mem_limit' => 'int',
Expand All @@ -979,6 +980,8 @@ function acp()
'fulltext_sphinx_autoconf' => '1',
'fulltext_sphinx_autorun' => '1',
'fulltext_sphinx_indexer_mem_limit' => '512',
'fulltext_sphinx_min_word_len' => '1',
'fulltext_sphinx_ip' => '127.0.0.1',
);

foreach ($config_vars as $config_var => $type)
Expand Down Expand Up @@ -1086,11 +1089,19 @@ function acp()
<dt><label for="fulltext_sphinx_data_path">' . $user->lang['FULLTEXT_SPHINX_DATA_PATH'] . ':</label><br /><span>' . $user->lang['FULLTEXT_SPHINX_DATA_PATH_EXPLAIN'] . '</span></dt>
<dd><input id="fulltext_sphinx_data_path" type="text" size="40" maxlength="255" name="config[fulltext_sphinx_data_path]" value="' . $config['fulltext_sphinx_data_path'] . '" /></dd>
</dl>
<dl>
<dt><label for="fulltext_sphinx_min_word_len">' . $user->lang['FULLTEXT_SPHINX_MIN_WORD_LEN'] . ':</label><br /><span>' . $user->lang['FULLTEXT_SPHINX_MIN_WORD_LEN_EXPLAIN'] . '</span></dt>
<dd><input id="fulltext_sphinx_min_word_len" type="text" size="2" maxlength="2" name="config[fulltext_sphinx_min_word_len]" value="' . $config['fulltext_sphinx_min_word_len'] . '" /></dd>
</dl>
<span class="error">' . $user->lang['FULLTEXT_SPHINX_CONFIGURE_AFTER']. '</span>
<dl>
<dt><label for="fulltext_sphinx_stopwords">' . $user->lang['FULLTEXT_SPHINX_STOPWORDS_FILE'] . ':</label><br /><span>' . $user->lang['FULLTEXT_SPHINX_STOPWORDS_FILE_EXPLAIN'] . '</span></dt>
<dd><label><input type="radio" id="fulltext_sphinx_stopwords" name="config[fulltext_sphinx_stopwords]" value="1"' . (($stopwords_active) ? ' checked="checked"' : '') . ((!$stopwords_available) ? ' disabled="disabled"' : '') . ' class="radio" /> ' . $user->lang['YES'] . '</label><label><input type="radio" name="config[fulltext_sphinx_stopwords]" value="0"' . ((!$stopwords_active) ? ' checked="checked"' : '') . ' class="radio" /> ' . $user->lang['NO'] . '</label></dd>
</dl>
<dl>
<dt><label for="fulltext_sphinx_ip">' . $user->lang['FULLTEXT_SPHINX_IP'] . ':</label><br /><span>' . $user->lang['FULLTEXT_SPHINX_IP_EXPLAIN'] . '</span></dt>
<dd><input id="fulltext_sphinx_ip" type="text" size="16" maxlength="16" name="config[fulltext_sphinx_ip]" value="' . $config['fulltext_sphinx_ip'] . '" /></dd>
</dl>
<dl>
<dt><label for="fulltext_sphinx_port">' . $user->lang['FULLTEXT_SPHINX_PORT'] . ':</label><br /><span>' . $user->lang['FULLTEXT_SPHINX_PORT_EXPLAIN'] . '</span></dt>
<dd><input id="fulltext_sphinx_port" type="text" size="4" maxlength="10" name="config[fulltext_sphinx_port]" value="' . $config['fulltext_sphinx_port'] . '" /></dd>
Expand Down
8 changes: 6 additions & 2 deletions sphinx_plugin/language/en/mods/fulltext_sphinx.php
Expand Up @@ -53,8 +53,12 @@
'FULLTEXT_SPHINX_INDEXER_MEM_LIMIT_EXPLAIN' => 'This number should at all times be lower than the RAM available on your machine. If you experience periodic performance problems this might be due to the indexer consuming too many resources. It might help to lower the amount of memory available to the indexer.',
'FULLTEXT_SPHINX_LAST_SEARCHES' => 'Recent search queries',
'FULLTEXT_SPHINX_MAIN_POSTS' => 'Number of posts in main index',
'FULLTEXT_SPHINX_PORT' => 'Sphinx search deamon port',
'FULLTEXT_SPHINX_PORT_EXPLAIN' => 'Port on which the sphinx search deamon on localhost listens. Leave empty to use the default 3312',
'FULLTEXT_SPHINX_MIN_WORD_LEN' => 'Minimum indexed word length',
'FULLTEXT_SPHINX_MIN_WORD_LEN_EXPLAIN' => 'Only those words that are not shorter than this minimum will be indexed. For instance, if min_word_len is 4, then "the" won\'t be indexed, but "they" will be. Default is 1 (index everything).',
'FULLTEXT_SPHINX_IP' => 'Sphinx server IP address',
'FULLTEXT_SPHINX_IP_EXPLAIN' => 'IP address of the server running Sphinx search daemon. Default is localhost (127.0.0.1). If Sphinx runs on another server, you must manually copy the generated config file there. If you use the autorun option, Sphinx daemon must run on localhost.',
'FULLTEXT_SPHINX_PORT' => 'Sphinx search daemon port',
'FULLTEXT_SPHINX_PORT_EXPLAIN' => 'Port on which the sphinx search daemon listens. Leave empty to use the default 3312',
'FULLTEXT_SPHINX_REQUIRES_EXEC' => 'The sphinx plugin for phpBB requires PHP’s <code>exec</code> function which is disabled on your system.',
'FULLTEXT_SPHINX_UNCONFIGURED' => 'Please set all necessary options in the "Fulltext Sphinx" section of the previous page before you try to activate the sphinx plugin.',
'FULLTEXT_SPHINX_WRONG_DATABASE' => 'The sphinx plugin for phpBB currently only supports MySQL',
Expand Down

0 comments on commit 35c2dfb

Please sign in to comment.