coreseek php配置案例

发布时间:2020-06-06 01:49:44 作者:13548725997
来源:网络 阅读:524

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

推荐阅读:
  1. PHP编码规范
  2. php+bootstrap+dataTable+jquery分页列表

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php sphinx coreseek

上一篇:AD用户批量创建和属性修改工具推荐-ADBulkAdmin

下一篇:Mysql数据库之创建用户

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》