# # minimal sphinx configuration sample (clean, simple, functional) # source src1 { type = mysql sql_host = localhost sql_user = root sql_pass = root sql_db = test sql_port = 3306 # optional, default is 3306 sql_query_pre = set names utf8 sql_query = \ select 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 } searchd { listen = 9312 listen = 9306:mysql41 log = /usr/local/sphinx/log/searchd.log query_log = /usr/local/sphinx/log/query.log read_timeout = 5 max_children = 30 pid_file = /usr/local/sphinx/log/searchd.pid seamless_rotate = 1 preopen_indexes = 1 unlink_old = 1 binlog_path = /usr/local/sphinx/data }
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->setserver($host, $port); $sphinx->setconnecttimeout(10); $sphinx->setarrayresult(true); $sphinx->setmatchmode(sph_match_all); $res = $sphinx->query($q, $index); print_r($res);
运行结果如下:
结束,记得数据库数据改变后需重新生成索引
如对本文有疑问, 点击进行留言回复!!
php 使用 yansongda/pay 进行微信,支付宝支付
Codeforces Round #658 (Div. 2) (C1、C2)
van-uploader + thinkphp6.0 图片上传
网友评论