Installation and use of Coreseek

Source: Internet
Author: User
Tags automake

Search Structure PHP--Sphinx MySQL unstructured data is also called full-text data,non-fixed-length fields such as article title Search this kind of applicable Sphinx full-text data search: Sequential scan: Like look-up Index Scan: Extract the contents of unstructured data out part of the reorganize,This part of the data is called Index full-text search is divided into two processes1. Creating an index2. Search index CREATE INDEX: Sphinx The Language processing component will place punctuation in the search statement, the modal particles are filtered out,and then, after the processing, some words are analyzed ., passed to the index component,the sorting is then removed by repeating words. Search index: Search keyword submission, sphinx analysis of the document ID--MySQL ID query data and return Chinese word segmentation needs Coreseekcoreseek Support Chinese full-text search engine Sphinx installation Download source package for source installation./configure--prefix=/usr/local/sphinx--with-mysql=/usr/local/mysqlmake && make Installsphinx important three commands (under Bin directory) Indexer CREATE INDEX command searchd START process command Search Command-line Search command configuration SPHINXCD/USR/LOCAL/SPHINX/ETCCP sphinx.conf.dist SPHINX.CONFVI sphinx.conf The primary data source with the configuration file name main: source main{} Inherit the incremental data source named main: source delta:main{} Primary index named main: Index main{} inherits the Delta index named main: Index delta:main{} Distributed index: Index dist1{} indexer: indexer{} service process: searchd{} Modify the MySQL configuration of the primary data source in the configuration file, the data source for the test environment is named Main,Suppose MySQL test has a table called Postsource main{# Data source type. Mandatory,No default value # Known types is MySQL, Pgsql, MSSQL, Xmlpipe, Xmlpipe2,ODBC Type=MySQL ##################################################################### # # SQL settings (for ' MySQL ' and ' p  Gsql ' Types) ##################################################################### # some straightforward parameters For SQL source Types Sql_host=localhost sql_user=Root Sql_pass=Admin sql_db=Test Sql_port= 3306 # optional, default is 3306Sql_sock=/tmp/mysqld.sock #如果是linux下需要开启,Specify sock file Sql_query_pre=SET NAMES UTF8 sql_query_pre= SET SESSION query_cache_type=OFF #关闭缓存 # main document FETCH query # mandatory,Integer document ID field must be the first selected column Sql_query=\ #获取数据的sql语句 SELECT ID, title,content from Post #sql_attr_uint=group_id #对排序字段进行注释 #sql_attr_timestamp=date_added #对排序字段进行注释 sql_query_info= SELECT * from post WHERE id=$id} comment out all incremental data sources,Modify Primary index main{source=Main # index files path and file name,without extension # mandatory, path must be writable,extensions'll be auto-appended path=/usr/local/sphinx/var/data/main DocInfo=extern Mlock= 0morphology=None # Default is1(index everything) Min_word_len= 1# CharSet encoding type # optional,default is ' SBCs ' # known types be ' SBCs ' (single Byte CharSet) and ' utf-8' Charset_type= Utf-8# ' utf-8' default value is # charset_table= 0..9, A.. Z->a. Z, _, a.. Z, u+410..u+42f->u+430..u+44f, u+430.. u+44f} comment out all incremental indexes and after the distributed index configuration is complete,CREATE INDEX command indexer-c Specify configuration file--all index all indexes--rotate used for rotating indexes, mainly in the non-stop service,Increase index--merge merge index/usr/local/sphinx/sbin/indexer-c/usr/local/sphinx/etc/sphinx--all if error./indexer:error while Loading shared libraries:libmysqlclient.so.18: Cannot open shared object File:no such file or directory solution: cp/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib/libmysqlclient.so.18Test Build Index[[email protected] bin]#./indexer--allsphinx0.9.9-release (r2117) Copyright (c)2001-2009,Andrew aksyonoffusing config file '/usr/local/sphinx/etc/sphinx.conf ' ... indexing index ' main ' ... collected2 Docs, 0.0mbsorted0.0 mhits, 100.0% donetotal2 Docs, 47Bytestotal0.033 sec, 1414 Bytes/sec, 60.21Docs/sectotal1 Reads, 0.000 sec, 0.0 kb/call avg, 0.0Msec/call avgtotal5 writes, 0.000 sec, 0.0 kb/call avg, 0.0msec/call avg Search[[email protected] bin]#./search Linux1sphinx0.9.9-release (r2117) Copyright (c)2001-2009,Andrew aksyonoffusing config file '/usr/local/sphinx/etc/sphinx.conf ' ... index ' main ': Query ' linux1 ': Returned 1 matches of 1 total in 0.000secdisplaying matches:1. Document=1, Weight=1ID=1title=linux1 Content=salflsdkjsdgldswords:1. ' Linux1 ': 1 documents, 1Hitssphinx is equivalent to static database data index to the local to speed up the query speed to avoid consuming the database, give the database to buck, when the data is updated,need to re-indexer--all or rebuild all indexes with indexer main to search for new data installation Coreseekcoreseek has 2 folders one is mmseg Chinese word breaker and one is csft (actually sphinx) package Install mmseg Chinese participle first./configure--prefix=/usr/local/mmseg compile may error config.status:error:cannot find input file:src/ Makefile.in through Automake to resolve the first check if Libtool installed if there is no yum-y install Libtoolautomake if automake error reason may be the following Libtool library used  But ' LIBTOOL ' is undefinedthe usual-define ' LIBTOOL ' is-to-add ' ac_prog_libtool ' to ' configure.ac ' and run ' aclocal ' and ' autoconf ' again. If ' Ac_prog_libtool ' is in ' configure.ac ',Make sureits definition was in aclocal ' s search path. Cause Analysis Aclocal is a scanner., is responsible for scanning all macro definitions and configure.ac in theThe reason for this is that the definition of the Libtool macro cannot be found. The reason is that aclocal and Libtool are not installed under the same directory aclocal is to go to the default installation directory/usr/share/ Aclocal Search all the. m4 files below for the defined macros, but due to the installation of multiple aclocal, the aclocal directory may not exist, the actual directory is/usr/share/aclocal1.10, etc.This causes the aclocal to find the M4 file., the workaround is to rename the folder aclocal1.10 to aclocal. or display the specified path aclocal-i/usr/share/aclocal1.10-i/usr/share/libtool/m4--install or copy the files under/usr/share/libtool/m4 to/usr/share/aclocal1.10. On my machine is/usr/ There are 2 folders under Share/one is aclocal, one is aclocal-1.11, first copy all aclocal files to Aclocal-1. 11 down cp-r/user/share/aclocal/*/usr/share/aclocal-1.11/Then rerun aclocal and Autoconfaclocal && autoconf finally run Automakeautomake again and continue with mmseg installation./configure--prefix=/usr/local/mmsegmake && make install if make error there is a easy fix if you get such messages as"X--tag=cxx:command not Found". Just Type:export Echo=Echoand try again. So enter export echo=Echo and then run the install again && make install csft./configure--prefix=/usr/local/coreseek--with-mysql=/usr/local/mysql--with-mmseg=/usr/local/mmseg--with-mmseg-includes=/usr/local /mmseg/include/mmseg/--with-mmseg-libs=/usr/local/mmseg/lib/make && make install after installation, note that the configuration files in Coreseek are also csft.conf and not sphinx.confcd/usr/local/ CORESEEK/ETCCP sphinx.conf.dist Csft.confvim csft.conf Some configuration changes as shown in the previous sphinx.conf in the index source commented out Txtindex main{# Stopwords=G:\data\stopwords.txt #wordforms=G:\data\wordforms.txt #exceptions=/data/exceptions.txt #charset_type=SBCs #添加下面2行 means to add Chinese participles to the configuration file Char_type= Zh_cn.utf-8Charset_dictpath=/usr/local/mmseg/etc/#你安装mmseg的目录} Save Configuration Build index Cd/usr/local/coreseek/bin./indexer--all./search Chinese affix how to use PHP to Sphinxsphinx integration into a PHP program in two ways1. Sphinx PHP Module (this time we chose to use the way)2.Sphinx API Class (in the Coreseek source package in the csft in the API folder there is a sphinxapi.php,Include this PHP file when using it) we need to do the following things to use Sphinx:1. First, you need to have data2. Setting up the Sphinx configuration file3. Build an index4, start the SEARCHD service process,and open port 93125. Use PHP client to link Sphinx Service/usr/local/coreseek/bin/searchd START process command searchd-c Specify configuration file--stop stop service--pidfile display specified PID file-p specified port (default 9312) Note: The service started here is searchd using PHP Sphinx module Download sphinx-1.1.0. Tgztar zvxf sphinx-1.1.0. TGZCD sphinx-1.1.0/usr/local/php/bin/phpize #用于生成一个configure的脚本进入coreseek源码包的csft/api/libsphinxclent directory execution configure./ Configuremake && make install enter sphinx-1.1.0The Shpinx module that configure is used to generate so is executed under the source package directory of the. gzt./configure--with-php-config=/usr/local/webserver/php/bin/php-config--with-sphinxmake && make install will be prompted to build complete after successful installation. Don ' t forget to run ' make test '. Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/(This directory is the directory where the Sphinx.so is located) and then we edit the PHP ini file in extension to add extension=sphinx.so then restart Nginx and PHP services finally print phpinfo to see if the Sphinx is successful if you open it, you can use the Sphinx method and code in the PHP manual.

This article turns from http://www.cnblogs.com/lost-1987/articles/2681643.html

Installation and use of Coreseek

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.