mysql coreseek_Coreseek使用
到這個(gè)鏈接下下載會(huì)得到coreseek-4.1-win32文件,把他解壓到C:\usr\local\目錄下
將文件 C:\usrlocal\coreseek-4.1-win32\var\test\documents.sql 導(dǎo)入到mysql中test(這個(gè)數(shù)據(jù)庫(kù)可以根據(jù)你自己的來設(shè)置)數(shù)據(jù)庫(kù)中。
編輯文件 C:\usr\local\coreseek-4.1-win32\etc\csft_mysql.conf 修改成你的配置,
sql_host = localhost
sql_user = root
sql_pass =
sql_db = test
sql_port = 3306
sql_query_pre = SET NAMES utf8
把以下路徑修改正確,注意,一定要絕對(duì)路徑
path = c:/usr/local/coreseek-4.1-win32/var/documents #請(qǐng)修改為實(shí)際使用的絕對(duì)路徑,這個(gè)目錄自己創(chuàng)建一下
charset_dictpath = c:/usr/local/coreseek-4.1-win32/etc/
pid_file = c:/usr/local/coreseek-4.1-win32/var/log/searchd_mysql.pid #請(qǐng)修改為實(shí)際使用的絕 對(duì)路徑
log = c:/usr/local/coreseek-4.1-win32/var/log/searchd_mysql.log
query_log = c:/usr/local/coreseek-4.1-win32/var/log/query_mysql.log
建立索引
dos進(jìn)入bin目錄,輸入
indexer -c C:\usr\local\coreseek-4.1-win32\bin\sphinx.conf --all
打開控制臺(tái)讓Sphinx監(jiān)聽端口,接收搜索命令
輸入C:\usr\local\coreseek-4.1-win32\bin\searchd.exe --install --config C:\usr\local\coreseek-4.1-win32\bin\sphinx.conf --servicename Coreseek
//這個(gè)地方的sphinx.conf,看了網(wǎng)上別人寫的教程。。很有問題。這個(gè)文件要有對(duì)應(yīng)的文件存在,否則會(huì)報(bào)錯(cuò)。
在php中使用
再把C:\usrlocal\coreseek-4.1-win32\api下的sphinxapi.php拷貝到你的項(xiàng)目文件夾下運(yùn)行下面的代碼,大功告成。
require ( "sphinxapi.php" );
header('Content-Type: text/html; charset=utf-8');//防止中文顯示為亂碼
$s = new SphinxClient;//已經(jīng)引入擴(kuò)展,所以不需要額外require文件了
$s->setServer("127.0.0.1", 9312);
$s->setMatchMode(SPH_MATCH_PHRASE);
$s->setMaxQueryTime(30);
$res = $s->query('Twitter主頁(yè)改版', 'mysql'); #[愚人]關(guān)鍵字,[mysql]數(shù)據(jù)源source
$err = $s->GetLastError();
echo '
';var_dump($res['matches']);
var_dump($err);
echo '
';命令
停止服務(wù)sc stop Coreseek
卸載服務(wù)sc delete Coreseek
重建索引indexer -c C:\usr\local\coreseek-4.1-win32\bin\sphinx.conf --rotate --all
總結(jié)
以上是生活随笔為你收集整理的mysql coreseek_Coreseek使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: native2ascii
- 下一篇: JDK 8 新特性 之 函数接口