当前位置:首页 > PHP > 正文内容

php sphinx 全文检索 中文分词

高老师3年前 (2022-11-26)PHP816

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

扫描二维码推送至手机访问。

版权声明:本文由高久峰个人博客发布,如需转载请注明出处。

本文链接:https://blog.20230611.cn/post/222.html

分享给朋友:

“php sphinx 全文检索 中文分词” 的相关文章

PHP生成微信分享需要的signature签名

PHP生成微信分享需要的signature签名

因为一个TP项目中客户需要全部网页分享支持自定义图片和描述信息,于是自己封装了下 //share()微信分享链接 //参数1 appid //参数2 appsert //参数3 nonceStr随机码 //参数4 timestamp时间戳 public&nb...

php将html转为pdf,php将html页面导出pdf

php将html转为pdf,php将html页面导出pdf

首先下载wkhtmltox-0.12.4_linux-generic-amd64.tar.xz   (不要下载RPM包,依赖太多,需要x-server支持),并解压,执行测试运行正常tar wkhtmltox-0.12.4_linux-generic-amd64.tar.xzcd...

编写php com组件,php调用.net dll,php源码保护

编写php com组件,php调用.net dll,php源码保护

开发com组件可以用c++,vc++,net,我比较熟悉net,演示用dnet(1).创建项目:启动vs2017,新建项目,选择Visual C# ->Windows桌面->类库通用windows(2). 修改Com项目:点击 项目->项目属性,再点击应用程序->程序集信息,...

php json_encode 使用注意

php json_encode 使用注意

参数中包含gb2312的字符串,返回结果是false或者null(不同PHP版本具有差异性)代码:<?php $dbms = 'mysql'; $host = '192.168.8.8'; $dbName =&n...

posix_ttyname函数详解

posix_ttyname函数详解

posix_ttyname - 获取当前终端设备名称。<?php     var_dump( posix_ttyname(STDOUT) );我们启动一个终端,执行上面的代码输出:/dev/tty1我们再启动一个终端,执行上面的代码输...

 thinkphp5定时任务,tp5定时任务,thinkphp定时任务,php定时任务,php定时器

thinkphp5定时任务,tp5定时任务,thinkphp定时任务,php定时任务,php定时器

本教程使用的定时任务基于EasyTak,EasyTask官方文档:https://gitee.com/392223903/EasyTask(1).安装tp5.0或者5.1composer create-project topthink/think=5.0.* tp5&n...