1, installation Coreseek
1.1 First upgrade or install system dependent libraries
Yum install make gcc g++ automake libtool mysql-client libmysqlclient15-dev libxml2-dev Libexpat1-dev
1.2 Downloads Coreseek3.2.14
Decompression: Tar zxvf coreseek-3.2.14.tar.gz
CD coreseek-3.2.14 CD mmseg-3.2.14 #在安装前首先安装mmseg插件./configure--prefix=/data/apps/mmseg3
If you report the following error
Config.status:creating Makefile config.status:creating src/makefile config.status:error:cannot Find input file: Src/makefile.in
Solve by installing autoconf and Automake
Yum-y Install autoconf automake aclocal configure.in:26:warning:macro ' am_prog_libtool ' not found in library y Um-y Install Libtool aclocal libtoolize--force libtoolize:putting auxiliary files in Ac_config_aux_dir, ' confi G '. libtoolize:linking file ' config/ltmain.sh ' Libtoolize:consider adding ' ac_config_macro_dir ([M4]) ' to configure.in and Libtoolize:rerunning Libtoolize, to keep the correct Libtool macros In-tree. Libtoolize:consider Adding '-I M4 ' to Aclocal_amflags in makefile.am. Automake--add-missing autoconf Autoheader make clean
Complete the above operation, reconfigure can
./configure--prefix=/data/apps/mmseg3------------------------------------------------------------------------ Configuration:source code location:. COMPILER:GCC Compiler Flags:-g-o2 Host System type:x86_64-redhat-linux-gnu Install Path:/data/apps/mmseg3 See Config.h for further configuration information. ------------------------------------------------------------------------
Installing MMSEG
Make && make install Test-z "/DATA/APPS/MMSEG3/ETC" | | /bin/mkdir-p "/data/apps/mmseg3/etc"/usr/bin/install-c data/unigram.txt data/uni.lib Data/mmseg.ini '/Data/apps/ Mmseg3/etc ' make[2]: Leaving directory '/data/tgz/coreseek-3.2.14/mmseg-3.2.14 ' make[1]: Leaving directory '/DATA/TG Z/coreseek-3.2.14/mmseg-3.2.14 '
1.3 After installing MMSEG Chinese word plug-in, you can install Coreseek3.2.14.
Ln-s/data/apps/mmseg3/bin/mmseg/bin/mmseg CD. CD csft-3.2.14/./configure--prefix=/data/apps/coreseek--without-unixodbc--with-mmseg-includes=/data/apps/mmseg3 /include/mmseg/--with-mmseg-libs=/data/apps/mmseg3/lib/--with-mysql make && make install
Through the above steps, Mmseg and Coreseek3.2.14 on the installation completed, through the LS command to view the installed directory and files
[Email protected] csft-3.2.14]# Ls/data/apps/coreseek/bin etc var
2, detection coreseek Chinese word
1, CD/DATA/TGZ/CORESEEK-3.2.14/TESTPACK/2,/data/apps/mmseg3/bin/mmseg-d/data/apps/mmseg3/etc var/test/test.xml 3, /data/apps/coreseek/bin/indexer-c etc/csft.conf--all, if error unigram dictionary load error, modify:/data/tgz/ The Charset_dictpath = var/mmseg3/etc/path in coreseek-3.2.14/testpack/etc/csft.conf is: Charset_dictpath =/Data/apps/mmseg3 /etc/can be 4,/data/apps/coreseek/bin/search-c etc/csft.conf network search, error is as follows index ' XML ': Search error:failed to open var/data/x Ml.sph:No such file or directory.
Resolved as follows:
Yum Install expat-devel* and reinstall Sphinx/coreseek
Re-execute command:/data/apps/coreseek/bin/search-c etc/csft.conf web Search
Coreseek fulltext 3.2 [Sphinx 0.9.9-release (r2117)] Copyright (c) 2007-2011, Beijing Choice software Technologies INC (http://www.coreseek.com) using config file ' etc/csft.conf ' ... index ' XML ': Query ' network search ': returned 1 matches of 1 total In 0.010 sec displaying matches:1 document=1, Weight=1, Published=thu Apr 1 15:20:07, author_id=1 words:1. ' Net Collateral ': 1 documents, 1 hits 2. ' Search ': 2 documents, 5 hits
3. Configure Coreseek and use
3.1. Copy the instance configuration to the ETC directory of the installation Coreseek
Cp/data/tgz/coreseek-3.2.14/testpack/etc/csft_mysql.conf/data/apps/coreseek/etc/csft_mysql.conf
3.2. Modify the configuration file
Vim/data/apps/coreseek/etc/csft_mysql.conf
SOURCE mysql{type = mysql Sql_host = localhost sql_user = Test Sql_pass = root sql_db = Kp_account Sql_port = 3306 sql_query _pre = SET NAMES UTF8 sql_query = SELECT goods_id, goods_id as GID, Goods_name, add_time from Fc_goods #sql_query第一列id需为整数 #title, content as a string/text field, is full-text indexed sql_attr_uint = GID #从SQL读取到的值必须为整数 Sql_attr_timestamp = Add_time #从SQL读取到的值必须为整数, as time attribute sql_query_info_pre = SET NAMES UTF8 #命令行查询时, set the correct character set sql_query_info = SELECT * from documents WHERE id= $id #命令行查询时, read from database Raw Data Information} #index定义index mysql{Source = mysql #对应的source名称 path =/data/apps/coreseek /var/data/mysql #请修改为实际使The absolute path used, for example:/usr/local/coreseek/var/... docinfo = extern Mlock = 0 morphology = None Min_word_len = 1 Html_strip = 0 #中文分词配置, see for details: Http://www.coreseek.cn/products-install/corese ek_mmseg/#charset_dictpath =/usr/local/mmseg3/etc/#BSD, linux settings,/end of symbol Charset_dictpath =/data/apps/mmseg3/etc/ #charset_dictpath = etc/#Windows环境下设置,/end of symbol, it is best to give absolute path, for example: 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 = Max_matches = Seamless_rot ate = 0 preopen_indexes = 0 Unlink_old = 1 pid_file =/data/apps/coreseek/var/log/search D_mysql.pid #请修改为实际使用的绝对路径, for example:/usr/local/coreseek/var/... log =/data/apps/coreseek/var/log/searchd_mysql.log # Please modify the absolute path to actually use, for example:/usr/local/coreseek/var/Query_log =/data/apps/coreseek/var/log/query_mysql.log #请修改为实际使用的绝对路径, for example:/usr/local/coreseek /var/...}
Save
3.3. Building an Index
/data/apps/coreseek/bin/indexer-c/data/apps/coreseek/etc/csft_mysql.conf--all
Prompt after successful creation
Coreseek fulltext 3.2 [Sphinx 0.9.9-release (r2117)]copyright (c) 2007-2011,beijing Choice software Technologies Inc (htt p://www.coreseek.com) using config file '/data/apps/coreseek/etc/csft_mysql.conf ' ... indexing index ' mysql ' ... Collected 811 docs, 0.0 mbsorted 0.0 mhits, 100.0% donetotal 811 docs, 15729 bytestotal 0.072 sec, 217260 bytes/sec, 11202 . Docs/sectotal 2 Reads, 0.000 sec, 14.2 kb/call avg, 0.0 msec/call avgtotal 7 writes, 0.000 sec, 10.3 kb/call avg, 0.0 Msec/call avg
3.4. Start the service
/data/apps/coreseek/bin/searchd-c/data/apps/coreseek/etc/csft_mysql.conf
4, using Sphinx There are two ways, one is to install PHP Sphinx extension, the second is to use the Sphinx interface, where the Sphinx interface is used directly
4.1. Copy the sphinxapi.php file to the project directory
CP api/sphinxapi.php/data/apps/nginx/html/sphinx/
4.2, PHP call Sphinx interface to search
<?php require ("sphinxapi.php"); $sphinx = new Sphinxclient (); $sphinx->setserver ("127.0.0.1", 9312); $keyword = $_get[' keyword ')? $_get[' keyword ': ' Tires '; $res = $sphinx->query ($keyword, ' MySQL '); Print_r ($res);
Operation Result:
Array ([ERROR] = [WARNING] = [status] = 0 [Fields] = = Array ([0] = goods_name) [Attrs] = = Array ( [GID] = 1 [add_time] + 2) [matches] + array ([1] = = Array ([weight] + 1 [attrs] + = Array ([GID] + 1 [add_time] = 1411609439)) [2] = = Array ([weight] = 1 [attrs] = = Array ([GID] = 2 [Add_time] = = 1411610728)) [3] = = Array ([weight] = 1 [attrs] = = Array ([GID] = 3 [add_time] + 1411610941) ) [4] = = Array ([weight] = 1 [attrs] = = Array ([GID] = 4 [add_time] = 1411611452)) [5] = = Array ([Weight] = 1 [attrs] = Array ([gid] = 5 [add_time] + 1411612148)) [6] = = Array ([weight] = 1 [attrs] = = Array ([GID] = 6 [add_time] = 1411670735)) [7] = = Array ([ Weight] = 1 [attrs] + array ([GID] = 7 [Add_time] = 1411670863)) [8] = = Array ([weight] = 1 [at TRS] + Array ([gid] = 8 [Add_time] = 1411671000)) [9] = = Array ([weight] = 1 [attrs] = = Array ([GID] = 9 [Add_time] = 1411671203)) [+] = Ar Ray ([Weight] = 1 [attrs] = Array ([GID] = [add_time] = 1411671953) [one] = = Array ([weight] =& Gt 1 [attrs] = = Array ([GID] = [add_time] = 1411672386)) [[Weight] = Array ([attrs] = 1 [[+]] = A Rray ([gid] = [Add_time] + 1411672846)) [+] = array ([weight] = 1 [attrs] = = Array ([GID] => ; [Add_time] = 1411673187)) [[] = = Array ([weight] = 1 [attrs] = = Array ([GID] = [Add_time] =&G T 1411675395)) [+] = array ([weight] = 1 [attrs] = = Array ([GID] = [Add_time] + 1411675806)) [1 7] = = Array ([weight] = 1 [attrs] = = Array ([GID] = [add_time] = 1411675957)) [] = = Array ( [Weight] = 1 [attrs] = Array ([GID] = [add_time] = 1411676124)) [+] = array ([weight] = 1 [Attrs] = ARray ([gid] = [add_time] = 1411676262)) [+] = array ([weight] = 1 [attrs] = = Array ([GID] => ; [Add_time] = 1411676661)) [[] = = Array ([weight] + 1 [attrs] = = Array ([GID] = [Add_time] =&G T 1411676864)) [total] [total_found] = [TIME] = 0.017 [words] = = Array ([auto] = = Array ([docs ] = [hits] + 57)))
Summary: To this, it has been basically integrated into PHP, and then integrated into the thinkphp.
coreseek+sphinx+mysql+thinkphp Integration