(1).下载3.4.1版本
http://sphinxsearch.com/downloads/current/
(2).配置数据源和索引(超精简版本)
#
# Minimal Sphinx configuration sample (clean, simple, functional)
#
source question_src
{
type = mysql
sql_host = 187.99.929.99
sql_user = legaojiufeddssdg
sql_pass = HjwmzCwALiGSDGfdf
sql_db = learojiufengfdfd
sql_port = 3306 # optional, default is 3306
sql_query = \
SELECT id,course_id,question_name \
FROM think_course_question
#sql_attr_uint = id
sql_attr_uint = course_id
}
index question
{
source = question_src
path = D:/test/indexData/
ngram_len = 1
ngram_chars = U+3000..U+2FA1F
}
indexer
{
mem_limit = 128M
}
searchd
{
listen = 9312
listen = 9306:mysql41
log = D:/test/log/searchd.log
query_log = D:/test/log/query.log
read_timeout = 5
max_children = 30
pid_file = D:/test/searchd.pid
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = D:/test/data/
}
(3).生成索引
indexer.exe -c ../etc/sphinx-min.conf question
(4).启动sphinx
./searchd.exe -c ../etc/sphinx-min.conf
(5).php启动查询
$cl = new SphinxClient ();
$cl->SetServer($config['host'], $config['port']);
$cl->SetConnectTimeout(1);
$cl->SetLimits(0, $limit, 100);
$res = $sphinxClient->Query($keyword, 'question');