安装coreseek过程

浏览:7400 发布日期:2015/11/06 分类:技术分享 关键字: coreseek
写这个是为了防止大家跟我一样,少走弯路,分享经验
下载sphinx地址:
http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz
包含coreseek和mmseg3
解压coreseek-3.2.14.tar.gz
#安装mmseg
cd mmseg-3.2.14
./bootstrap #输出的warning信息可以忽略,如果出现error则需要解决
./configure --prefix=/usr/local/mmseg3
make && make install
cd ..
#安装coreseek
cd csft-3.2.14
sh buildconf.sh #输出的warning信息可以忽略,如果出现error则需要解决
./configure --prefix=/usr/local/coreseek --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql ##如果提示mysql问题,可以查看MySQL数据源安装说明
make && make install
cd ..

cd /usr/local/coreseek/etc
cp sphinx.conf.dist sphinx.conf
vi sphinx.conf
#测试mmseg分词 coreseek搜索(需要预先设置好字符集为zh_CN.UTF-8,确保正确显示中文)
cd testpack
cat ./var/test/test.xml #此时应该正确显示中文
/usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc ./var/test/test.xml
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all
/usr/local/coreseek/bin/search -c /usr/local/coreseek/etc/sphinx.conf 网络搜索

#安装php的sphinx扩展
#在https://pecl.php.net里面找sphinx扩展
下载解压
configure: error: Cannot find libsphinxclient headers
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
提示报错
configure: error: Cannot find libsphinxclient headers
应该是没有这个libsphinxclient
coreseek里面的api文件夹下面有这个依赖包coreseek-3.2.14/csft-3.2.14/api/libsphinxclient

./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/libsphinxclient

在php.ini加入extension=sphinx.so
重启服务 应该OK

coreseek的使用
/usr/local/coreseek/bin
在这个下面启动searched服务,监听端口是9312
建立索引
如果searched启动的状态下要加--rotate参数,
./indexer --all --rotate

php调用sphinx api试试查询结果
<?php
function p($arr){
echo "<pre>";
print_r($arr);
}
$obj=new SphinxClient();

$obj->SetServer('127.0.0.1',9312);
$obj->SetMatchMode(SPH_MATCH_EXTENDED);
var_dump($obj->GetLastError());
$rzt=$obj->Query('test','*');
var_dump($obj->GetLastError());
$obj->close();
p($rzt);

输出结果:client version is higher than daemon version (client is v.1.25, daemon is v.1.22)

客户端版本太高了 我擦
最后测试要用sphinx-1.3.2.tgz这个版本的才行,重启lnmp,终于有结果了source src1
{
    type                    = mysql
    sql_host                = 127.0.0.1
    sql_user                = root
    sql_pass                = 
    sql_db                    = shop
    sql_port                = 3306

    sql_query_pre            = SET NAMES utf8
    sql_query_pre            = SET SESSION query_cache_type=OFF


    sql_query                = \
        select gd_goods.goods_id gid,gd_goods.goods_img gimg,goods_name,gd_goods.goods_sn,color,size from gd_goods \
         left join gd_goods_attr on gd_goods.goods_id = gd_goods_attr.goods_id where is_delete=0;

    sql_attr_uint            = gid

}


index test1
{
    source            = src1

    path            = /usr/local/coreseek/var/data/test1

    docinfo            = extern

    charset_dictpath=/usr/local/mmseg3/etc

    charset_type = zh_cn.utf-8

    ngram_len                = 0
}

indexer
{
    mem_limit            = 32M

}


searchd
{
    listen                = 127.0.0.1:9312
    # listen                = /var/run/searchd.sock


    log                    = /usr/local/coreseek/var/log/searchd.log

    query_log            = /usr/local/coreseek/var/log/query.log

    read_timeout        = 5

    client_timeout        = 300

    max_children        = 30

    # PID file, searchd process ID file name
    # mandatory
    pid_file            = /usr/local/coreseek/var/log/searchd.pid

    max_matches            = 1000

    seamless_rotate        = 1

    preopen_indexes        = 0

    unlink_old            = 1

}
function p($arr){
echo "<pre>";
print_r($arr);
}
$obj=new SphinxClient();

$obj->SetServer('127.0.0.1',9312);
$obj->SetArrayResult(true);
$rzt=$obj->Query('2015冬装新品','*');
$obj->close();
最佳答案
评论( 相关
后面还有条评论,点击查看>>