我希望使用 sphinx 返回的结果来搜索子字符串。
我的设置好吗?
我需要重新启动该searchd
过程吗?
index dev_jobs
{
source = dev_jobs_src
path = /home/sphinx/jobs/dev_jobs
docinfo = extern
charset_type = utf-8
enable_star = 1
min_infix_len = 3
}
searchd
{
port = 9312
log = /var/log/sphinx/searchd.log
query_log = /var/log/sphinx/query.log
read_timeout = 5
max_children = 30
pid_file = /var/run/sphinx/searchd.pid
max_matches = 100000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
}
和代码的php部分:
$sphinx_search = Yii::app()->search;
$sphinx_search->setSelect('*');
$sphinx_search_final = '';
$sphinx_search_query = trim($this->q);
if (strlen($sphinx_search_query) > 0) {
$sphinx_search_query = str_replace('-', ' ', $sphinx_search_query);
$keys = explode(' ', $sphinx_search_query);
foreach ($keys as $k => $key) {
if ($key) {
$keys[$k] = $key;
} else {
unset($keys[$k]);
}
}
if (count($keys) > 0) {
$sphinx_search_final = ' @(position_name,employer_name,employer_first_name,employer_last_name,employer_position) ' . $sphinx_search_query .
' @(position_name,employer_name,employer_first_name,employer_last_name,employer_position) ' . implode('|', $keys);
}
}