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);
}
}