LaneBlog

蝼蚁虽小,也有梦想

PHP Socket服务 | PHP微信开发框架 | 开源博客

CoreSeek Mysql 安装与测试 For Mac OS X(中文分词与中文全文检索)

Clicks: 5441 Date: 2014-09-02 14:27:43 Power By 李轩Lane

    

    CoreSeek安装比较麻烦,官方手册对此的支持并不算很好。CoreSeek是基于Sphinx的中文的分词和全文检索软件。本文是在MAC OS X系统下安装和调试CoreSeek。

    安装过程中报错如果是警告warning则忽略,如果是错误error,则必须要处理。

    CoreSeek是支持三种数据来源的,一种是众所周知的Mysql,一种是XML文件,另一种是Python。而Python则是万能数据类型。在本CoreSeek安装测试教程中只示例数据源是XML文件和MYSQL。


    官方手册地址:http://www.coreseek.cn/products-install/install_on_macosx


    一、设置环境变量


$ export PATH=/usr/local/bin:$PATH

$ export LC_ALL=zh_CN.UTF-8

$ export.UTF-8


    二、安装依赖库:m4、autoconf、automake、libtool。

注意:不要brew install 来安装,因为对安装的库的版本有要求。

$ curl -O -L http://mirrors.kernel.org/gnu/m4/m4-1.4.13.tar.gz

$ tar -xzvf m4-1.4.13.tar.gz

$ cd m4-1.4.13

$ sudo ./configure --prefix=/usr/local/opt

$ sudo make

$ sudo make install

$ cd ..


$ curl -O -L http://mirrors.kernel.org/gnu/autoconf/autoconf-2.65.tar.gz

$ tar -xzvf autoconf-2.65.tar.gz

$ cd autoconf-2.65

$ sudo ./configure --prefix=/usr/local/opt

$ sudo make

$ sudo make install

$ cd ..


$ curl -O -L http://mirrors.kernel.org/gnu/automake/automake-1.11.tar.gz

$ tar xzvf automake-1.11.tar.gz

$ cd automake-1.11

$ ./configure --prefix=/usr/local/opt

$ sudo make

$ sudo make install

$ cd ..


$ curl -O -L http://mirrors.kernel.org/gnu/libtool/libtool-2.2.6b.tar.gz

$ tar xzvf libtool-2.2.6b.tar.gz

$ cd libtool-2.2.6b

$ sudo ./configure --prefix=/usr/local/opt

$ sudo make

$ sudo make install

$ cd ..


    三、安装Mysql。

1、mysql 的安装自行安装

2、查找mysql头文件地址和库文件地址。我用

brew install mysql

安装的Mysql,头文件地址和库文件地址分别是/usr/local/Cellar/mysql/5.6.17_1/include/mysql 和 /usr/local/Cellar/mysql/5.6.17_1/lib。

头文件地址就是mysql.h所在的目录,库文件地址就是libmysqlclient.a所在的目录。


    四、下载Coreseek。

$ curl -O -L http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz

$ tar xzvf coreseek-3.2.14.tar.gz

$ cd coreseek-3.2.14

在coreseek-3.2.14文件夹下有mmseg和csft和testpack。mmseg是分词服务,csft是CoreSeek的核心服务,testpack是测试用例。


    五、安装mmseg

$ cd mmseg-3.2.14

$ sudo ./bootstrap

$ sudo ./configure --prefix=/usr/local/opt/mmseg3

$ sudo make

$ sudo make install

$ cd ..

在make的时候,可能会报错,如下

file included from css/ThesaurusDict.cpp:6:

../src/css/ThesaurusDict.h:12:17: error: expected namespace name

using namespace __gnu_cxx;

^

css/ThesaurusDict.cpp:79:15: warning: result of comparison against a string

literal is unspecified (use strncmp instead) [-Wstring-compare]

if (filename == "-") {

    ^ ~~~

    css/ThesaurusDict.cpp:116:15: warning: result of comparison against a string

literal is unspecified (use strncmp instead) [-Wstring-compare]

if (filename != "-") {

    ^ ~~~

    2 warnings and 1 error generated.

    make[2] : *** [ThesaurusDict.lo] Error 1

make[1]: *** [install-recursive] Error 1


这个时候make进程已经终止。原因是因为编译器版本太高导致的,修改方法:1是降低编译器版本,反正我打死也不愿意。方法2如下:

vim src/css/ThesaurusDict.h

###在头部找到:#include <string>

###再其下加入一行代码:

#include <ext/hash_map>

修改完后保存退出,继续重新sudo make一下,就没有error级错误了,然后sudo make install即可。


    六、安装coreseek

$ cd csft-3.2.14

$ sudo sh buildconf.sh

$ sudo ./configure --prefix=/usr/local/opt/coreseek  --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/opt/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/opt/mmseg3/lib/ --with-mysql --with-mysql-includes=/usr/local/Cellar/mysql/5.6.17_1/include/mysql --with-mysql-libs=/usr/local/Cellar/mysql/5.6.17_1/lib

$ sudo make

$ sudo make install

$ cd ..

在./configure时,参数--with-mysql-includes是mysql头文件位置,--with-mysql-libs是mysql库文件位置,请在本CoreSeek安装教程第三步所记录的mysql头文件地址和库文件地址,替换。


在make时,可能又会出现error级的错误,如果出现make程序是停止运行的,必须要修改。错误提示如下:

phinxexpr.cpp:1047:11: error: use of undeclared identifier 'ExprEval'

T val = ExprEval ( this->m_pArg, tMatch ); // 'this' fixes gcc ...


解决方法:修改源代码。

vim src/sphinxexpr.cpp

将T val = ExprEval( this->m_pArg, tMatch )替换为T val = this->ExprEval ( this->m_pArg, tMatch )。

就是加了个“this->”,是把这个文件中所有的ExprEval()函数都修改了,有三四个吧。

修改后保存退出,重新sudo make,然后sudo make install即可。


    七、测试XML数据

$ cd testpack


#测试编码是否正确显示中文,如果不是中文则请看本CoreSeek安装测试教程第一步

$ cat var/test/test.xml


# 测试mmseg分词的效果

$ /usr/local/opt/mmseg3/bin/mmseg -d /usr/local/opt/mmseg3/etc var/test/test.xml 


# 建立检索的索引。

$ /usr/local/opt/coreseek/bin/indexer -c etc/csft.conf --all


#全文搜索“网络搜索”

$ /usr/local/opt/coreseek/bin/search -c etc/csft.conf 网络搜索

如果在建立检索的索引出错,FATAL: failed to lock var/data/xml.spl: Resource temporarily unavailable, will not index. Try --rotate option.

则修改为

$ /usr/local/opt/coreseek/bin/indexer -c etc/csft.conf --all --rotate



    八、测试MYSQL数据源

cd testpack


1、修改配置文件,文件位于testpack/etc/csft_mysql.conf

vim etc/csft_mysql.conf

我的csft_mysql.conf文件如下:记得把mysql 的sql_host,sql_user,sql_pass,sql_db,sql_port修改为自己的,并且把路劲都修改为你自己的路径。

#MySQL数据源配置,详情请查看:http://www.coreseek.cn/products-install/mysql/

#请先将var/test/documents.sql导入数据库,并配置好以下的MySQL用户密码数据库


#源定义

source mysql

{

    type                    = mysql


    sql_host                = localhost

    sql_user                = root

    sql_pass                = 8823150

    sql_db                    = test

    sql_port                = 3306

    sql_query_pre            = SET NAMES utf8


    sql_query                = SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content FROM documents

                                                              #sql_query第一列id需为整数

                                                              #title、content作为字符串/文本字段,被全文索引

    sql_attr_uint            = group_id           #从SQL读取到的值必须为整数

    sql_attr_timestamp        = date_added #从SQL读取到的值必须为整数,作为时间属性


    sql_query_info_pre      = SET NAMES utf8                                        #命令行查询时,设置正确的字符集

    sql_query_info            = SELECT * FROM documents WHERE id=$id #命令行查询时,从数据库读取原始数据信息

}


#index定义

index mysql

{

    source            = mysql             #对应的source名称

    path            = /Users/lane/coreseek-3.2.14/testpack/var/data/mysql #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...

    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/opt/mmseg3/etc/ #BSD、Linux环境下设置,/符号结尾

    #charset_dictpath = etc/                             #Windows环境下设置,/符号结尾,最好给出绝对路径,例如:C:/usr/local/coreseek/etc/...

    charset_type        = zh_cn.utf-8

}


#全局index定义

indexer

{

    mem_limit            = 128M

}


#searchd服务定义

searchd

{

    listen                  =   9312

    read_timeout        = 5

    max_children        = 30

    max_matches            = 1000

    seamless_rotate        = 0

    preopen_indexes        = 0

    unlink_old            = 1

    pid_file = /Users/lane/coreseek-3.2.14/testpack/var/log/searchd_mysql.pid  #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...

    log = /Users/lane/coreseek-3.2.14/testpack/var/log/searchd_mysql.log        #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...

    query_log = /Users/lane/coreseek-3.2.14/testpack/var/log/query_mysql.log #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...

}


2、给mysql导入测试数据

    mysql的测试数据我们用的是test数据库,documents数据表。请自行确保test数据库存在,我们一起来建documents表,这个表的结构和数据都是由CoreSeek提供的,在testpack/var/test/documents.sql

mysql -u root -p

#输入密码


#看看,数据库test在不在

mysql > show databases; 

#如果test库不在请创建

mysql > create database test;


use test;


#导入数据

source /Users/lane/coreseek-3.2.14/testpack/var/test/documents.sql


3、测试:

$ cd testpack


# 建立检索的索引

$ /usr/local/opt/coreseek/bin/indexer -c etc/csft_mysql.conf --all


#全文搜索“网络搜索”

$ /usr/local/opt/coreseek/bin/search -c etc/csft_mysql.conf 网络搜索

如果提示有错误,请检查csft_mysql.conf的路径、mysql的配置等信息是否正确。



    九、测试PHP+MYSQL

1、先启动服务

/usr/local/opt/coreseek/bin/searchd -c etc/csft.conf

2、PHP文件

<?php

require ( "/Users/lane/coreseek-3.2.14/testpack/api/sphinxapi.php" );


$cl = new SphinxClient ();

$cl->SetServer ( '127.0.0.1', 9312);

$cl->SetConnectTimeout ( 3 );

$cl->SetArrayResult ( true );

$cl->SetMatchMode ( SPH_MATCH_ANY);

$res = $cl->Query ( '网络搜索', "*" );

print_r($cl);

print_r($res);



我在Linux折腾了一天没有搞定,在MAC搞了半天搞定了。等搞定Linux后再发Linux的。

Reply: Danielshirm On 2020-06-19 17:54:50

legal to buy prescription drugs without prescription <a href=http://onlinepharmacyero.com/#>viagra without a doctor prescription</a> http://onlinepharmacyero.com viagra walmart viagra sale america

回复

Reply: Eliashoalo On 2020-06-19 23:15:58

amoxicillin without a doctor's prescription <a href=" http://onlinepharmacyero.com/# ">cheap pet meds without vet prescription</a> onlinepharmacyero.com prescription drugs without doctor approval

回复

Reply: Murraynib On 2020-06-20 00:16:49

prescription drugs online without <a href=" http://onlinepharmacyero.com/# ">ed meds online without prescription or membership</a> onlinepharmacyero.com real viagra without a doctor prescription

回复

Reply: Danielshirm On 2020-06-22 16:27:49

prescription drugs <a href=http://onlinepharmacyero.com/#>prescription drugs canada buy online</a> http://onlinepharmacyero.com cialis super active buy can buy cheap viagra

回复

Reply: Jeromecoofs On 2020-06-23 01:06:55

cialis money order <a href=" http://bestpricemedz.com/# ">buy generic cialis</a> bestpricemedz.com generic viagra

回复

Reply: Jamescog On 2020-06-24 02:41:32

canadian viagra cialis <a href=" http://bestpricemedz.com/# ">viagra without doctor prescription</a> bestpricemedz.com cialis generic

回复

Reply: JeromeAgile On 2020-06-24 03:48:46

http://bestpricemedz.com/# generic viagra

回复

Reply: Jeromecoofs On 2020-06-24 19:54:57

generic cialis at walgreens pharmacy <a href=" http://bestpricemedz.com/# ">generic cialis</a> bestpricemedz.com cialis vs viagra

回复

Reply: Jeromecoofs On 2020-06-25 17:32:36

5mg cialis <a href=" http://bestpricemedz.com/# ">viagra without doctor prescription</a> bestpricemedz.com generic viagra

回复

Reply: JeromeAgile On 2020-06-26 06:55:20

http://bestpricemedz.com/# generic cialis

回复

Reply: Russellbub On 2020-06-26 15:16:39

does cialis make you bigger <a href=" http://www.ccnau.cn/space-uid-154447.html ">cialis without doctor prescription</a> and <a href=" http://xingsewo.com/space-uid-874153.html ">cialis without doctor prescription</a> and <a href=" http://dt.minfish.com/home.php?mod=space&uid=182383 ">generic viagra</a> and <a href=" http://oldps.com/home.php?mod=space&uid=242703 ">cheap cialis</a> and <a href=" http://bunbun000.com/bbs/home.php?mod=space&uid=2193460 ">cialis</a> and <a href=" http://bbs.tobycc.com/home.php?mod=space&uid=58692 ">cialis generic</a> http://www.zqykj.com/bbs/home.php?mod=space&uid=3285 generic cialis

回复

Reply: LarryZen On 2020-06-27 08:21:52

hard erections cialis <a href=" http://www.harmoniemill.nl/guestbook?page=1&anonname=lrrklkje&anonemail=bestpr18%40cialisfavdrug.com&message=%3Ca%20href%3Dhttp%3A%2F%2Fforum.sirumem.com%2Fmember.php%2F632591-yxckfgzg%3Eed%20meds%20online%20canada%3C%2Fa%3E%20for%20%3Ca%20href%3Dhttps%3A%2F%2Fwww.hack82.com%2Fspace-uid-87478.html%3Eprescription%20drugs%20without%20doctor%20approval%3C%2Fa%3E%20for%20%3Ca%20href%3Dhttp%3A%2F%2Fwww.xdceo.com%2Fspace-uid-96219.html%3Eprescription%20without%20a%20doctor%27s%20prescription%3C%2Fa%3E%20for%20%3Ca%20href%3Dhttp%3A%2F%2Fwww.phycn.com%2Fbbs%2Fhome.php%3Fmod%3Dspace%26uid%3D201530%3Eed%20meds%20online%20canada%3C%2Fa%3E%20for%20%3Ca%20href%3Dhttp%3A%2F%2Fwww.haribaby.com%2Fhome.php%3Fmod%3Dspace%26uid%3D34026%3Egoogle%20viagra%20dosage%20recommendations%3C%2Fa%3E%20for%20%3Ca%20href%3Dhttp%3A%2F%2Fsjyh.sseuu.com%2Fspace-uid-4472234.html%3Ebuy%20prescription%20drugs%20online%20without%3C%2Fa%3E%20for%20%3Ca%20href%3Dhttp%3A%2F%2Fgubibo.com%2Fhome.php%3Fmod%3Dspace%26uid%3D93790%3Eamo ">cialis vs viagra</a> and <a href=" http://direct-forum.com/memberlist.php?mode=viewprofile&u=23350 ">cialis generic</a> and <a href=" http://carbattle.net/People/hrffalony/People/Jamesdar/People/wxsolxlw/ ">cialis without doctor prescription</a> and <a href=" http://hksecurity.colorso.com/home.php?mod=space&uid=24101 ">buy generic cialis</a> and <a href=" http://toupiao2.625555.net/home.php?mod=space&uid=721729 ">viagra without doctor prescription</a> and <a href=" http://property.malaysiamostwanted.com/profiles/ooxplxlz ">generic cialis</a> http://jz.yinuo1000.cn/home.php?mod=space&uid=1767074 cialis vs viagra

回复

Reply: Jamescog On 2020-06-27 11:31:08

generic cialis <a href=" http://www.ss2015.net/space-uid-27903.html ">cheap cialis</a> and <a href=" http://wz.kjwww.cn/home.php?mod=space&uid=3062 ">generic viagra</a> and <a href=" http://niubi.gg/home.php?mod=space&uid=124373 ">buy cialis</a> and <a href=" http://www.junmi360.com/home.php?mod=space&uid=494389 ">cialis without doctor prescription</a> and <a href=" http://www.merccentre.com/index.php/component/users/?option=com_k2&view=itemlist&task=user&id=634200 ">generic cialis</a> and <a href=" http://www.chiapaspictures.com/profile.php?uid=901777 ">cialis without doctor prescription</a> http://nytva.org/memberlist.php?mode=viewprofile&u=167738 buy generic cialis

回复

Reply: MatthewBuire On 2020-06-28 18:58:01

cost of cialis 20mg tablets <a href=" http://www.bluelightbride.com/member.php?action=profile&uid=78586 ">cialis price</a>, <a href=" http://www.chinesejian.com/home.php?mod=space&uid=588185 ">cialis price</a>, <a href=" http://bbs.gaibar.com/space-uid-169951.html ">cialis online</a>, <a href=" http://www.mir6.com/home.php?mod=space&uid=17919 ">cialis price</a>, <a href=" http://www.harmoniemill.nl/guestbook?page=1&anonname=cvvgvubx&anonemail=isusdolw26%40cialisfavdrug.com&message=%5Burl%3Dhttp%3A%2F%2Fwww.littlefx.com%2Fmember.php%3F272214-wtcpxilz%5Dcialis%20without%20doctor%20prescription%5B%2Furl%5D%20for%20%5Burl%3Dhttp%3A%2F%2Fcnoocim.com%2Fspace-uid-541591.html%5Dcialis%20generic%5B%2Furl%5D%20for%20%5Burl%3Dhttp%3A%2F%2Fjedlykastan.cz%2FphpBB3%2Fmemberlist.php%3Fmode%3Dviewprofile%26u%3D25218%5Dgeneric%20viagra%5B%2Furl%5D%20for%20%5Burl%3Dhttp%3A%2F%2Fbongdaplut.net%2Fplus%2Fprofile.php%3Fid%3D705006%5Dcheap%20cialis%5B%2Furl%5D%20for%20%5Burl%3Dhttp%3A%2F%2Fzhuli.icoolcn.com%2Fhome.php%3Fmod%3Dspace%26uid%3D1472178%5Dgeneric%20viagra%5B%2Furl%5D%20for%20%5Burl%3Dhttp%3A%2F%2F2xex.com%2Fhome.php%3Fmod%3Dspace%26uid%3D463557%5Dviagra%20without%20doctor%20prescription%5B%2Furl%5D%20for%20%5Burl%3Dhttp%3A%2F%2Fwww.lg1212.com%2Fhome.php%3Fmod%3Dspace%26uid%3D6248%5Dgeneric%20viagra%5B%2Furl%5D%20for%20%5Burl%3Dhttp%3A%2F%2F666weixiu.com%2Fhome.php%3Fmod ">generic cialis</a>, <a href=" http://jilucisheng.com/home.php?mod=space&uid=43863 ">cialis</a>, <a href=" http://bbs.998ml.com/home.php?mod=space&uid=36309 ">buy cialis online</a>

回复

Reply: Victorjully On 2020-06-29 10:20:21

what is cialis used for <a href=" http://www.132330.com/home.php?mod=space&uid=178549 ">buy generic cialis</a> and <a href=" http://bocauvietnam.com/member.php?649010-sjbvtfct ">cialis 20mg</a> and <a href=" http://www.hangzhour.com/home.php?mod=space&uid=46616 ">cialis coupon</a> and <a href=" http://change-e.cn/bbs/home.php?mod=space&uid=179025 ">cialis</a> and <a href=" http://www.myfule.com/home.php?mod=space&uid=383361 ">buy cialis online</a> and <a href=" http://bbs.mcrst.com/home.php?mod=space&uid=1233969 ">cialis</a> http://www.wuzhishan.hn.cn/home.php?mod=space&uid=2734363 cialis price

回复

Reply: JesusChuth On 2020-06-29 13:18:51

cialis generic availability <a href=" http://www.ganen12.com/bbs/space-uid-159458.html ">generic cialis</a> and <a href=" http://www.bieshuw.com/bbs/home.php?mod=space&uid=1569818 ">buy generic cialis</a> and <a href=" https://www.bahismaster.com/member.php?443552-duqcarof ">buy cialis online</a> and <a href=" http://oldps.com/home.php?mod=space&uid=259846 ">buy generic cialis</a> and <a href=" http://forum.muhanoixua.com.vn/member.php?36105-mjupbmve ">cialis price</a> and <a href=" http://forum.muss3.vn/member.php?97027-inullovd ">buy cialis online</a> http://lsdsng.com/user/91881 buy cialis

回复

Reply: AnthonyBuh On 2020-06-30 04:36:19

take cialis with or without food <a href=" http://vikefans.com/community/index.php?action=profile;u=658153 ">cialis 20mg</a> and <a href=" http://intergraphbbs.com/member.php?mod=register&hash=bfe3KkxTTOkcuIV%2FoBrBltsMHnIZXyZZeIEsenHw91wKPuOxDZA8HcF0jkJ%2BEjSf5xY23Fnebh%2BvQE81DfbXET%2F0RA&email=uispoel14@cialisfavdrug.com ">cialis online</a> and <a href=" http://www.yahaosi.com/bbs/home.php?mod=space&uid=1759050 ">cialis coupon</a> and <a href=" http://www.nanajch.com/home.php?mod=space&uid=75180 ">buy cialis online</a> and <a href=" http://www.wixin.wang/home.php?mod=space&uid=798303 ">generic cialis</a> and <a href=" http://www.myyunku.com/space-uid-59759.html ">generic cialis</a> what is cialis used for <a href=" http://nxfhc.com/bbs/home.php?mod=space&uid=332382 ">buy generic cialis</a> and <a href=" https://www.ai0123.top/home.php?mod=space&uid=34363 ">cialis coupon</a> and <a href=" http://bbs.zszytz.com/home.php?mod=space&uid=655574 ">cialis</a> and <a href=" http://www.wuzhishan.hn.cn/home.php?mod=space&uid=2734329 ">generic cialis</a> and <a href=" http://bxlm100.com/home.php?mod=space&uid=594383 ">cialis</a> and <a href=" http://jilucisheng.com/home.php?mod=space&uid=43627 ">cialis price</a> http://www.huaiyinluntan.com/space-uid-61396.html generic cialis

回复

Reply: ShannonHab On 2020-07-02 02:25:39

cialis coupons 2019 <a href=" http://tadalafilprof.com/# ">cialis</a> tadalafilprof.com - switching from tamsulosin to cialis

回复

Add Comment
©2014 www.lanecn.com , All rights reserved. Power By Li Xuan.  京ICP备14005030号