您好,登錄后才能下訂單哦!
require ( "sphinxapi.php" );
$cl = new SphinxClient ();
$cl->SetServer ( '127.0.0.1', 9312);
$cl->SetConnectTimeout ( 3 );
$cl->SetArrayResult ( true );
$cl->SetMatchMode ( SPH_MATCH_ANY);
$cl->SetFilter ( "typeid", array (1) );
//$cl->SetMatchMode ( SPH_MATCH_EXTENDED );//設置模式
$cl->SetRankingMode ( SPH_RANK_PROXIMITY );//設置評分模式
$cl->SetFieldWeights(array('thickness'=>30,'width'=>20,'size'=>20,'catename'=>10,'warehouse'=>10,'mark'=>10,'factory'=>10,'level'=>10,'price'=>10,'caseno'=>10,'socket'=>10,'remark'=>10));
$cl->SetSortMode ('SPH_SORT_EXPR','@weight');
//$cl->SetLimits(0,100, 100);
$res = $cl->Query ( '0.007 電纜', "*" );
header("Content-type: text/html; charset=utf-8");
//print_r($cl);
print_r($res);
新建delta.bat文件:
@ECHO off
D:\coreseek-3.2.14-win32\bin\indexer.exe --config D:\coreseek-3.2.14-win32\etc\csft_hyw_sale.conf delta --rotate
echo indexing, window will close when complete
新建merge.bat合并文件
@ECHO off
D:\coreseek-3.2.14-win32\bin\indexer.exe --config D:\coreseek-3.2.14-win32\etc\csft_hyw_sale.conf --merge main delta --rotate
echo indexing, window will close when complete
coreseek配置文件:
#
# Minimal Sphinx configuration sample (clean, simple, functional)
#
source main
{
type = mysql
sql_host = 172.20.101.65
sql_user = huiyewang
sql_pass = test@123
sql_db = huiyewang
sql_port = 3306 # optional, default is 3306
sql_query_pre = SET NAMES utf8
sql_query_pre = REPLACE INTO snto_sphinx_counter_sale SELECT 1, MAX(updatetime) FROM snto_search_sale
sql_query = \
SELECT searchid, updatetime, typeid, id, thickness,size,catename,warehouse,mark,factory,level,price,caseno,socket,remark \
FROM snto_search_sale \
WHERE updatetime>=$start AND updatetime<=$end
sql_query_range = SELECT 1451577600,max_updatetime FROM snto_sphinx_counter_sale WHERE counter_id=1
sql_range_step = 864000
#sql_ranged_throttle = 0
sql_attr_uint = typeid
sql_attr_uint = id
sql_attr_timestamp = updatetime
sql_query_info = SELECT * FROM snto_search_sale WHERE searchid=$id
}
source delta
{
type = mysql
sql_host = 172.20.101.65
sql_user = huiyewang
sql_pass = test@123
sql_db = huiyewang
sql_port = 3306 # optional, default is 3306
sql_query_pre = SET NAMES utf8
sql_query_pre = SET NAMES utf8
sql_query = SELECT searchid, updatetime, typeid, id, thickness,size,catename,warehouse,mark,factory,level,price,caseno,socket,remark FROM snto_search_sale \
WHERE updatetime >( SELECT max_updatetime FROM snto_sphinx_counter_sale WHERE counter_id=1 )
sql_query_post = REPLACE INTO snto_sphinx_counter_sale SELECT 1, MAX(updatetime) FROM snto_search_sale
#字符串屬性設置、需要過濾、排序的時候用到
sql_attr_uint = typeid
sql_attr_uint = id
sql_attr_timestamp = updatetime
sql_query_info = SELECT * FROM snto_search_sale WHERE searchid=$id
}
index main
{
source = main
path = D:/coreseek-3.2.14-win32/data/main
docinfo = extern
mlock = 0
morphology = none
min_word_len = 1
html_strip = 0
#中文分詞配置,詳情請查看:http://www.coreseek.cn/products-install/coreseek_mmseg/
#charset_dictpath = /usr/local/mmseg3/etc/ #BSD、Linux環境下設置,/符號結尾
charset_dictpath = etc/ #Windows環境下設置,/符號結尾,最好給出絕對路徑,例如:C:/usr/local/coreseek/etc/...
charset_type = zh_cn.utf-8
}
#增量索引
index delta
{
source = delta
path = D:/coreseek-3.2.14-win32/data/delta
docinfo = extern
mlock = 0
morphology = none
min_word_len = 1
html_strip = 0
#中文分詞配置,詳情請查看:http://www.coreseek.cn/products-install/coreseek_mmseg/
#charset_dictpath = /usr/local/mmseg3/etc/ #BSD、Linux環境下設置,/符號結尾
charset_dictpath = etc/ #Windows環境下設置,/符號結尾,最好給出絕對路徑,例如:C:/usr/local/coreseek/etc/...
charset_type = zh_cn.utf-8
}
indexer
{
mem_limit = 128M
}
searchd
{
read_timeout = 5
max_children = 30
max_matches = 1000
seamless_rotate = 0
preopen_indexes = 0
unlink_old = 1
pid_file = var/log/searchd_mysql.pid #請修改為實際使用的絕對路徑,例如:/usr/local/coreseek/var/...
log = var/log/searchd_mysql.log #請修改為實際使用的絕對路徑,例如:/usr/local/coreseek/var/...
query_log = var/log/query_mysql.log #請修改為實際使用的絕對路徑,例如:/usr/local/coreseek/var/...
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。