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

php sphinx 全文检索 中文分词

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

(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 scoket,php webscoket,php webscoket 服务器

php scoket,php webscoket,php webscoket 服务器

项目需要使用websocket推送最新订单,客户服务器非linux不支持swoole,因此使用原生,直接上代码(1).PHP服务端<?php ini_set('error_reporting', E_ALL ^ E_NOTICE); ini_set...

 php xml字符串转数组,phpxml转数组,php 将xml转换成数组

php xml字符串转数组,phpxml转数组,php 将xml转换成数组

001源码:/*  * $xml_str是xml字符串  */ function  xmltoarray($xml_str) { //禁止XML实体扩展攻击 libxml_disable_entity_loader(true); //拒绝包含...

抛弃salt,使用password_hash()加密

抛弃salt,使用password_hash()加密

md5/sha1+salt方式是目前各大cms常用的加密方式,虽然salt安全,但是各大md5网站也在研究这个方向,那么我们应该选择password_hash动态hash来助力,一种密码有多种hash结果.看代码模拟登陆.<?php //01.注册 $user ='zhang...

php soap 捕获异常,使用try catch 捕获Soap 异常

php soap 捕获异常,使用try catch 捕获Soap 异常

项目中使用服务来执行webservice,由于对方系统api不稳定,经常导致服务崩溃,只能重启,一个月差不多要重启一次。初期的解决办法是捕获异常,然后continue掉。<?php try {     $url = 'http...

php上传大文件,php大文件上传

php上传大文件,php大文件上传

(1).前端文件:<form action="upload.php" method="post" enctype="multipart/form-data">    &...

php守护进程

php守护进程

<?php /**  * daemonize让当前脚本为守护进程执行  * @param string $callback 匿名函数  */ function daemonize($callback) {...