php sphinx 全文检索 中文分词

简介: php sphinx 全文检索 中文分词

(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');

目录
相关文章
|
jenkins Linux 持续交付
sphinx(五)php执行sphinx更新索引rotate命令
选择在更新数据的时候更新索引,这样做是为了保证数据检索的实时性,但是如果您的数据需要比较频繁的更新且数据量比较大,并且对数据检索没有实时性的要求,那么可以使用linux的定时任务,在使用人数较少的时候来更新索引,
125 0
sphinx(五)php执行sphinx更新索引rotate命令
|
搜索推荐 关系型数据库 MySQL
|
NoSQL PHP Redis
PHP+redis实现超迷你全文检索
2014年10月31日 11:45:39 情景: 我们平台有好多游戏, 运营的同事在查询某一款游戏的时候, 目前使用的是html的select下拉列表的展现形式, 运营的同事得一个个去找,然后选中,耗时又费眼 效果: 输入"三国"或者"国三", 将自动列出所有包含"三国"的游戏名字, 输入不限顺...
919 0