coreseek mmseg實驗記錄

mmseg
csft
testpack
http://blog.csdn.net/baidu_30000217/article/details/51771263 參考文章

yum install -y libtool automake
cd coreseek-3.2.14
cd mmseg-3.2.14/
./bootstrap
./configure --prefix=/usr/local/mmseg
make
make install

cd ..
cd csft-3.2.14/

這里我們要修改 src/sphinxexpr.cpp 文件,將該文件中的 1013、1047、1080 行的 ExprEval 改為

this->ExprEval(這里的行數(shù)跟網(wǎng)上的教程說的行數(shù)不一樣,可能是版本的問題吧,但是如果你用的是我提供的版本,該行數(shù)是正確的),懂點 C++

的同學也可以自己看看 ExprEval 錯在哪里。

改完上面所說的問題后:

./buildconf.sh

./configure
--prefix=/usr/local/coreseek
--with-mysql=/usr/local/mysql
--with-mmseg=/usr/local/mmseg
--with-mmseg-includes=/usr/local/mmseg/include/mmseg/
--with-mmseg-libs=/usr/local/mmseg/lib/

make && make install

###################z
中文分詞算法分類
1 基于字符串匹配的分詞方法
機械分詞法,基于詞典,在足夠大的詞典中進行詞條匹配 若找到了這個字符串,就算匹配成功(識別出一個詞)
三個要素
分詞詞典
文檔掃描順序 ---- 正向 逆向 雙向
匹配原則 ---- 最大 最小 逐詞 最佳
2 基于理解的分詞方法
3 基于統(tǒng)計的分詞方法

什么時候用sphinx
1 網(wǎng)站數(shù)據(jù)量日漸增大,對于搜索有更高的要求
2 網(wǎng)站用戶反映,搜索速度變的很慢
3 用戶很多數(shù)據(jù)很多處理大數(shù)量的并發(fā)查詢
4 設(shè)計一個千萬級或億級別的分布式架構(gòu)

配置文件
cp sphinx.conf.dist csft.conf

sphinxclient.c:1216:13: error: static declaration of 'sock_close' follows non-static declaration
static void sock_close ( int sock )

sphinx集成到php程序中,有兩種方式
1 sphinx php 模塊phpize???
cd /usr/local/src/coreseek-3.2.14/csft-3.2.14/api/libsphinxclient
./configure && make && make install
cd /usr/local/src/php-7.1.0/ext/sphinx-1.3.3
/usr/local/fastphp71/bin/phpize
./configure --with-php-config=/usr/local/fastphp71/bin/php-config --with-sphinx
make && make install

        出現(xiàn)這句話 說明安裝沒啥問題了
        Installing shared extensions:     /usr/local/fastphp71/lib/php/extensions/no-debug-non-zts-20160303/
        接下來修改配置文件
2   sphinx api 類(include)/usr/local/src/coreseek-3.2.14/testpack/api/sphinxapi.php

使用sphinx需要做以下事情
1 得有數(shù)據(jù)
2 建立sphinx配置文件
3 生成索引 indexer --all
4 啟動sphinx Searchd服務(wù)進程 開啟9312端口:/usr/local/coreseek/bin/searchd
-c 指定配置文件
--stop 停止服務(wù)
--pidfile 顯示指定一個pid文件
-p 指定端口
5 用php客戶程序去鏈接sphinx服務(wù)

#############實時索引#####
增量索引
主數(shù)據(jù)源 id 1、2、3
增量數(shù)據(jù)源 id 4 每5分鐘索引一次,晚上重新進行一次主索引(延遲5分鐘)
創(chuàng)建一個計數(shù)器表
create table sph_counter(counter_id int unsigned not null primary key auto_increment,max_doc_id,int not null);

修改sphinx配置文件添加到另外兩個sql_query_pre后面
sql_query_pre=replace into sphinx_counter select 1,max(id) from t1

再修改sql_query 加上條件
sql_query=select id,tit,cnf from t1 where id <= (select max_doc_id from sph_counter where counter_id = 1)

設(shè)置增量數(shù)據(jù)源
soucre delta:main{
    sql_query_pre=set names utf8;
    sql_query=select id,tit,cnt from t1 where id > (select max_doc_id from sph_counter where counter_id=1);
}
設(shè)置增量索引
index delta:main{
    source=delta
    path=/usr/local/coreseek/var/data/delta
}

開始測試增量索引
./indexer --all --rotate
先讀主數(shù)據(jù)源,更新到計數(shù)器表,生成索引到主數(shù)據(jù)索引


將增量數(shù)據(jù)新增索引
./indexer --delta --rotate 

寫兩個shell腳本 建兩個日志文件
main.sh

!/bin/bash

main.sh

/usr/local/coreseek/bin/indexer main --rotate >>/usr/local/coreseek/var/log/main.log

delta.sh

!/bin/bash

delta.sh

/usr/local/coreseek/bin/indexer delta --rotate >>/usr/local/coreseek/var/log/delta.log

crontab -e
*/12 * * * * /usr/local/coreseek/init/delta.sh
30 2 * * * /usr/local/coreseek/init/main.sh

給兩個shell腳本加權(quán)限
chmod a+x /usr/local/coreseek/init/*

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容