1.首先安装服务器预装环境
yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel
2.http://www.coreseek.cn/products-install/install_on_bsd_linux/ 官网有安装步骤 按照步骤安装即可
3.安装成功后,复制/root/coreseek-4.1-beta/testpack/etc/csft_mysql.conf至 /usr/local/coreseek/etc/文件夹下,
打开此文件,按照里面的配置项填写,
可能遇到的系统报错问题:
sql_attr_uint = article_id ##从SQL读取到的值必须为整数,会记录在返回的数组中attrs中,可填可不填,不填系统会报警告。
sql_attr_timestamp = datecreatedline #从SQL读取到的值必须为整数,作为时间属性 ,可填可不填
compat_sphinxql_magics=0 #本项原本文件中没有,但是由于在配置文件中设置的时候为1,所以如果不在此处改为0则系统会报错。
4.都配置完成后,按照以下步骤执行测试(xxxxxx为测试文件名,替换成自己的即可)
建立索引 /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/xxxxxx.conf --all
启动服务 /usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/xxxxxx.conf
此处可能会碰到pid报错问题,这是由于进程已被占用,通过 ps aux|grep searchd 指令查询进程,kill掉,再启动即可。因为只能出现一个进程,大多数是因为上一个进程没有关闭,例如刚刚安装完时测试过csft.conf,导致进程被它占用了,然后你新创建的则不能使用
##如要已启动服务,要更新索引,请使用/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/xxxxxx.conf --all --rotate
搜索测试: /usr/local/coreseek/bin/search -c /usr/local/coreseek/etc/xxxxxx.conf 我想搜索啦啦啦
//php接口
require ( "sphinxapi.php" );
$cl = new SphinxClient ();
$cl->SetServer ( '127.0.0.1', 9312);
$cl->SetConnectTimeout ( 3 );
$cl->SetArrayResult ( true );
$cl->SetMatchMode ( SPH_MATCH_ANY);
//SPH_SORT_RELEVANCE按权值排序
$pagesize=30;
$p = $_GET['p']?$_GET['p']:1;
$start= ($p-1)*$pagesize;
$cl->SetLimits($start,$pagesize,1000);//匹配结果的偏移量,参数的意义依次为:起始位置,返回结果条数,最大匹配条数
$res = $cl->Query ( '$search_text', "*" );
$res['matches']; //存储的是查询到的id
$res['total_found'];//存储的是查询到的真实的总数
yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel
2.http://www.coreseek.cn/products-install/install_on_bsd_linux/ 官网有安装步骤 按照步骤安装即可
3.安装成功后,复制/root/coreseek-4.1-beta/testpack/etc/csft_mysql.conf至 /usr/local/coreseek/etc/文件夹下,
打开此文件,按照里面的配置项填写,
可能遇到的系统报错问题:
sql_attr_uint = article_id ##从SQL读取到的值必须为整数,会记录在返回的数组中attrs中,可填可不填,不填系统会报警告。
sql_attr_timestamp = datecreatedline #从SQL读取到的值必须为整数,作为时间属性 ,可填可不填
compat_sphinxql_magics=0 #本项原本文件中没有,但是由于在配置文件中设置的时候为1,所以如果不在此处改为0则系统会报错。
4.都配置完成后,按照以下步骤执行测试(xxxxxx为测试文件名,替换成自己的即可)
建立索引 /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/xxxxxx.conf --all
启动服务 /usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/xxxxxx.conf
此处可能会碰到pid报错问题,这是由于进程已被占用,通过 ps aux|grep searchd 指令查询进程,kill掉,再启动即可。因为只能出现一个进程,大多数是因为上一个进程没有关闭,例如刚刚安装完时测试过csft.conf,导致进程被它占用了,然后你新创建的则不能使用
##如要已启动服务,要更新索引,请使用/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/xxxxxx.conf --all --rotate
搜索测试: /usr/local/coreseek/bin/search -c /usr/local/coreseek/etc/xxxxxx.conf 我想搜索啦啦啦
//php接口
require ( "sphinxapi.php" );
$cl = new SphinxClient ();
$cl->SetServer ( '127.0.0.1', 9312);
$cl->SetConnectTimeout ( 3 );
$cl->SetArrayResult ( true );
$cl->SetMatchMode ( SPH_MATCH_ANY);
//SPH_SORT_RELEVANCE按权值排序
$pagesize=30;
$p = $_GET['p']?$_GET['p']:1;
$start= ($p-1)*$pagesize;
$cl->SetLimits($start,$pagesize,1000);//匹配结果的偏移量,参数的意义依次为:起始位置,返回结果条数,最大匹配条数
$res = $cl->Query ( '$search_text', "*" );
$res['matches']; //存储的是查询到的id
$res['total_found'];//存储的是查询到的真实的总数