首页 > 作文

分词搜索 sphinx3.1.1+php7+mysql

更新时间:2023-04-07 12:15:08 阅读: 评论:0

下载sphinx3乒乓比赛.1.1wget http://sphinxarch.com/files/sphinx-3.1.1-612d99f-linux-amd64.tar.gz解压tar zxfsphinx-3.1.1-612d99f-linux-amd64.tar.gz改名 sphinx2017春晚小品 并移动到 /usr/local/mvsphinx-3.1.1 sphinxmvsphinx /usr/local/到sphinx目录下创建 data,log文件夹,并赋777权限cd /usr/local/sphinxmkdir datachmod -r 777 datamkdir logchmod -r 777 log在/usr/local/sphinx/etc 编写 sphinx.conf 配置文件cd/usr/local/sphinx/etcvimsphinx.conf
## minimal sphinx configuration sample (clean, simple, functional)#source src1{    type                = mysql    sql_host            = localhost    sql_ur            = root    sql_pass            = root    sql_db              = test    sql_port            = 3306    # optional, default is 3306    sql_query_pre       = t names utf8    sql_query            = \        lect id, group_id, unix_timestamp(date_added) as date_added, title, content \        from documents    sql_attr_uint        = group_id    sql_attr_timestamp    = date_added}index test1{    source                    = src1    path                    = /usr历史纪年表/local/sphinx/data    min_word_len            = 1    ngram_len               = 1    ngram_chars             = u+3000..u+2fa1f}indexer{    mem_limit        = 128m}archd{        listen                  = 9312        listen                  = 9306:mysql41        log                     = /usr/local/sphinx/log/archd.log        query_log               = /usr/local/sphinx/log/query.log        read_timeout            = 5        max_children            = 30        pid_file                = /usr/local/sphinx/log/archd.pid     高贵的近义词   amless_rotate         = 1        preopen_indexes         = 1        unlink_old              = 1        binlog_path             = /usr/local/sphinx/data}
在test数据库中 运行/usr/local/sphinx/etc目录下的example.sql文件进入mysqlu test;source /usr/local/sphinx/etc/example.sql添加索引/usr/local/sphinx/bin/indexer -c /usr/local/sphinx/etc/sphinx.conf test1运行sphinx师说一词多义/usr/local/sphinx/bin/archd -c /usr/local/sphinx/etc/sphinx.confphp操作sphinx下载sphinxapi.php 自带的类文件缺少function

https://files.cnblogs.com/files/wxzxc/sphinxclient.zip

$sphinx = new sphinxclient();$q      = $_get['key'] ?? 'test'; //搜索关键字$sql    = "";$host   = "127.0.0.1";$port   = 9312;$index  = "*";$sphinx->trver($host, $port);$sphinx->tconnecttimeout(10);$sphinx->tarrayresult(true);$sphinx->tmatchmode(sph_match_all);$res = $sphinx->query($q, $index);print_r($res);

运行结果如下:

结束,记得数据库数据改变后需重新生成索引

本文发布于:2023-04-07 12:15:05,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/85f00eba6b6951a8eca7ba1504042aa6.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:分词搜索 sphinx3.1.1+php7+mysql.doc

本文 PDF 下载地址:分词搜索 sphinx3.1.1+php7+mysql.pdf

标签:索引   文件   目录下   纪年
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图