coreseek php配置案例
更新:HHH   时间:2023-1-7


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/...
}

返回web开发教程...