配置好像是沒什麼問題的,在命令列下可以取得匹配結果,但是引入到PHP中卻沒有結果,用的是CORESEEK。
今天剛學sphinx,不知是哪裡出了問題,上網查也沒碰到類似問題:
這是設定檔:
#MySQL資料來源配置,詳情請查看:http://www.coreseek.cn/products-install/mysql/#請先將var/test/documents.sql匯入資料庫,並配置好以下的MySQL使用者密碼資料庫#源定義source cetsix{ type = mysql sql_host = localhost sql_user = root sql_pass = cai123 sql_db = words sql_port = 3306 sql_query_pre = SET NAMES UTF8sql_query = SELECT id, meaning ,lx FROM cetsix}#index定義index cetsix{ source = cetsix #對應的source名稱 path = E:\CodeEdit\php\ciba\niujin-alpha\sphinx\var\data\cetsix docinfo = extern mlock = 0 morphology = none min_word_len = 1 html_strip = 0 charset_dictpath = E:\CodeEdit\php\ciba\niujin-alpha\sphinx\etc charset_type = utf-8}indexer{ mem_limit = 128M}#searchd服務定義searchd{ listen = 3312 read_timeout = 5 max_children = 30 max_matches = 100 seamless_rotate = 1 preopen_indexes = 0 unlink_old = 1#最大允許的過濾器數 max_filters = 256 #每個過濾器最大允許的值的個數 max_filter_values = 4096#記錄檔儲存路徑 pid_file = E:\CodeEdit\php\ciba\niujin-alpha\sphinx\var\log\searchd_mysql.pid log = E:\CodeEdit\php\ciba\niujin-alpha\sphinx\var\log\searchd_mysql.log query_log = E:\CodeEdit\php\ciba\niujin-alpha\sphinx\var\log\query_mysql.log }
這是PHP測試代碼:
setServer("127.0.0.1", 3312);$sphinx->setMatchMode('SPH_MATCH_ANY');$res = $sphinx->query('man', "cetsix");var_dump($res);?>
資料庫編碼如下:
mysql> SHOW CREATE TABLE cetsix -> ;+--------+---------------------------------------------------| Table | Create Table+--------+---------------------------------------------------| cetsix | CREATE TABLE `cetsix` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `word` varchar(255) NOT NULL, `meaning` varchar(255) NOT NULL, `lx` text NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM AUTO_INCREMENT=13325 DEFAULT CHARSET=utf8 |+--------+---------------------------------------------------
在命令列下是可以返回結果的:
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
服務也啟動正常。。 真不知道是哪裡出了問題
回複討論(解決方案)
看了下手冊又解決了,送分拉
我去 大早上的看見有人送分
接分啦