前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >php sphinx 全文检索 中文分词

php sphinx 全文检索 中文分词

原创
作者头像
Thinker1024
发布2023-06-03 11:24:37
5910
发布2023-06-03 11:24:37
举报
文章被收录于专栏:编程语言的世界

(1).下载3.4.1版本

代码语言:javascript
复制
http://sphinxsearch.com/downloads/current/

(2).配置数据源和索引(超精简版本)

代码语言:javascript
复制
#
# 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).生成索引 

代码语言:javascript
复制
indexer.exe   -c    ../etc/sphinx-min.conf   question

(4).启动sphinx

代码语言:javascript
复制
./searchd.exe  -c   ../etc/sphinx-min.conf

(5).php启动查询

代码语言:javascript
复制
$cl = new SphinxClient ();
$cl->SetServer($config['host'], $config['port']);
$cl->SetConnectTimeout(1);
$cl->SetLimits(0, $limit, 100);
$res = $sphinxClient->Query($keyword, 'question');

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档