• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

sphinx匹配有关问题

php 搞代码 3年前 (2022-01-24) 20次浏览 已收录 0个评论

sphinx匹配问题
配置好像是没什么问题的,在命令行下可以取得匹配结果,但是引入到PHP中却没有结果,用的是CORESEEK。
今天刚学sphinx,不知是哪里出了问题,上网查也没碰到类似问题:
这是配置文件:

<br />#MySQL数据源配置,详情请查看:http://www.coreseek.cn/products-install/mysql/<br />#请先将var/test/documents.sql导入数据库,并配置好以下的MySQL用户密码数据库<br /><br />#源定义<br />source cetsix<br />{<br />    type                    = mysql<br />    sql_host                = localhost<br />    sql_user                = root<br />    sql_pass                = cai123<br />    sql_db                  = words<br />    sql_port                = 3306<br />    sql_query_pre           = SET NAMES UTF8<br />	sql_query               = SELECT id, meaning ,lx FROM cetsix<br />}<br /><br />#index定义<br />index cetsix<br />{<br />    source            = cetsix             #对应的source名称<br />    path              = E:\CodeEdit\php\ciba\niujin-alpha\sphinx\var\data\cetsix<br />    docinfo           = extern<br />    mlock             = 0<br />    morphology        = none<br />    min_word_len      = 1<br />    html_strip        = 0<br /><br />    charset_dictpath = E:\CodeEdit\php\ciba\niujin-alpha\sphinx\etc<br />    charset_type        = utf-8<br />}<br /><br />indexer<br />{<br />    mem_limit            = 128M<br />}<br /><br />#searchd服务定义<br />searchd<br />{<br />    listen                  = 3312<br />    read_timeout        	= 5<br />    max_children        	= 30<br />    max_matches             = 100<br />    seamless_rotate         = 1<br />    preopen_indexes         = 0<br />    unlink_old              = 1<br />	<br />	#最大允许的过滤器数<br />    max_filters        = 256<br />    #每个过滤器最大允许的值的个数<br />    max_filter_values  = 4096<br />	<br />	<br />	#日志文件保存路径<br />    pid_file = E:\CodeEdit\php\ciba\niujin-alpha\sphinx\var\log\searchd_mysql.pid  <br />    log = E:\CodeEdit\php\ciba\niujin-alpha\sphinx\var\log\searchd_mysql.log        <br />    query_log = E:\CodeEdit\php\ciba\niujin-alpha\sphinx\var\log\query_mysql.log <br />}<br />

这是PHP测试代码:

<br /><?php<br />header("content-type: text/html; charset=utf-8");<br />require_once "sphinxapi.php";<br />$sphinx = new SphinxClient();<br />$sphinx->setServer("127.0.0.1", 3312);<br />$sphinx->setMatchMode('SPH_MATCH_ANY');<br />$res = $sphinx->query('man', "cetsix");<br />var_dump($res);<br />?><br />

数据库编码如下:

<br />mysql> SHOW CREATE TABLE cetsix<br />    -> ;<br />+--------+---------------------------------------------------<br />| Table  | Create Table<br />+--------+---------------------------------------------------<br />| cetsix | CREATE TABLE `cetsix` (<br />  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,<br />  `word` varchar(255) NOT NULL,<br />  `meaning` varchar(255) NOT NULL,<br />  `lx` text NOT NULL,<br />  PRIMARY KEY (`id`)<br />) ENGINE=MyISAM AUTO_INCREMENT=13325 DEFAULT CHA<div style="color:transparent">!本文来源gaodai.ma#com搞##代!^码网(</div><sup>搞gaodaima代码</sup>RSET=utf8 |<br />+--------+---------------------------------------------------<br />

在命令行下是可以返回结果的:

C:\windows\system32>E:\CodeEdit\php\ciba\niujin-alpha\sphinx\bin\search.exe –c
onfig E:\CodeEdit\php\ciba\niujin-alpha\sphinx\sphinx.conf man
Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
Copyright (c) 2007-2011,
Beijing Choice Software Technologies Inc (http://www.coreseek.com)

using config file ‘E:\CodeEdit\php\ciba\niujin-alpha\sphinx\sphinx.conf’…
index ‘cetsix’: query ‘man ‘: returned 199 matches of 199 total in 0.001 sec

displaying matches:
1. document=4, weight=1
2. document=10, weight=1
3. document=24, weight=1
4. document=45, weight=1
5. document=186, weight=1
6. document=193, weight=1
7. document=239, weight=1
8. document=240, weight=1
9. document=394, weight=1
10. document=454, weight=1
11. document=466, weight=1
12. document=483, weight=1
13. document=514, weight=1
14. document=543, weight=1
15. document=653, weight=1
16. document=750, weight=1
17. document=930, weight=1

服务也启动正常。。 真不知道是哪里出了问题

——解决思路———————-
我去 大早上的看见有人送分
——解决思路———————-
接分啦


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:sphinx匹配有关问题

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址