1. Installation
1.1 Installing MMSEG
./Bootstrap # must be executed or the installation will fail. /configure--prefix=/usr/local/mmseg-3.2. - #指定安装目录 Make Make Install
1.2 Installing Coreseek
# in csft-4.1/Configure.ac # Find Am_init_automake ([-wall-Werror Foreign]) # change Am_init_automake ([-Wall foreign])SHBuildconf.SH# must be executed, or the installation will fail./configure--prefix=/usr/local/coreseek-4.1--with-mysql--with-mysql-includes=/usr/local/mysql-5.6. +/include--with-mysql-libs=/usr/local/mysql-5.6. +/lib--with-mmseg--with-mmseg-includes=/usr/local/mmseg-3.2. -/include/mmseg--with-mmseg-libs=/usr/local/mmseg-3.2. -/lib# in csft-4.1/src/Sphinxexpr.cpp in # Find T Val= Expreval (this->M_parg, Tmatch); # Replace T Val= This->expreval (this->M_parg, tmatch); Make Make Install
2. Configuration
Test data table Structure
CREATE TABLE' Sph_counter ' (' ID ')int(Ten) unsigned not NULLauto_increment, ' code 'varchar( -) not NULL DEFAULT "', `Max`int(Ten) unsigned not NULL, ' Add_time 'datetime not NULL, PRIMARY KEY(' id '),UNIQUE KEY' Code ' (' Code ') ENGINE=InnoDBDEFAULTCHARSET=UTF8;CREATE TABLE' movie ' (' movie_id ' )int(Ten) unsigned not NULLAuto_increment COMMENT'Movie ID', ' old_id 'int(Ten) unsigned not NULL DEFAULT '0'COMMENT'Old ID', ' SN 'varchar( -) not NULLCOMMENT'film designation', ' title 'varchar(255) not NULLCOMMENT'Film Name', ' cover 'varchar(255) not NULL DEFAULT "'COMMENT'Film Cover Map', ' publisher_id 'int(Ten) unsigned not NULLCOMMENT'Publisher ID', ' publish_date ' date not NULLCOMMENT'Release date', ' Add_time 'datetime not NULLCOMMENT'Add Time', PRIMARY KEY(' movie_id '),UNIQUE KEY' sn ' (' sn ')) ENGINE=InnoDBDEFAULTCHARSET=UTF8;
Coreseek Primary Index Configuration
Source main_javzoo_movie{Type=MySQL sql_host=127.0.0.1Sql_user=Root Sql_pass=sql_db=Javzoo Sql_port=3306# optional, default is3306Sql_query=SELECT movie_id, movie_id as record_id, title from movie WHERE movie_id>= $start and movie_id <=$end ORDER by movie_id ASC Sql_query_pre=SET NAMES UTF8 sql_query_pre= REPLACE into Sph_counter SET ' code ' ='movie', ' max ' = (SELECT max (movie_id) from movie), Add_time =Now () Sql_query_range= Select MIN (movie_id), (SELECT ' Max ' from ' sph_counter ' WHERE ' code ' ='movie') from movie Sql_range_step=10000Sql_attr_uint=record_id}index main_javzoo_movie_title{Source=Main_javzoo_movie Path=/usr/local/coreseek-4.1/var/data/Main_javzoo_movie_title Mlock=0morphology=None Min_word_len=1Html_strip=0DocInfo=extern Charset_type= zh_cn.utf-8Charset_dictpath=/usr/local/mmseg-3.2. -/etc Ngram_len=0}
3. Incremental configuration
Source delta_javzoo_movie{Type=MySQL sql_host=127.0.0.1Sql_user=Root Sql_pass=shia802927 sql_db=Javzoo Sql_port=3306Sql_query_pre=SET NAMES UTF8 sql_query_range= Select (SELECT ' Max ' from ' sph_counter ' WHERE ' code ' ='movie'), MAX (movie_id) from movie Sql_range_step=10000Sql_query=SELECT movie_id, movie_id as record_id, title from movie WHERE movie_id>= $start and movie_id <=$end ORDER by movie_id ASC sql_query_post= REPLACE into Sph_counter SET ' code ' ='movie', ' max ' = (SELECT max (movie_id) from movie), Add_time =Now () Sql_attr_uint=record_id}index delta_javzoo_movie_title{Source=Delta_javzoo_movie Path=/usr/local/coreseek-4.1/var/data/Delta_javzoo_movie_title Mlock=0morphology=None Min_word_len=1Html_strip=0DocInfo=extern Charset_type= zh_cn.utf-8Charset_dictpath=/usr/local/mmseg-3.2. -/etc Ngram_len=0}
4. Timed Update scripts
1#!/bin/SH-2Start_date= 'Date`3 EchoStart $1index @ $START _date4 5 if[" $"=" All" ]6 Then7/usr/local/coreseek-4.1/bin/indexer--config/usr/local/coreseek-4.1/etc/sphinx.conf--all--rotate >>/dev/NULL8 elif[" $"="Main" ]9 ThenTen/usr/local/coreseek-4.1/bin/indexer--config/usr/local/coreseek-4.1/etc/sphinx.conf main_javzoo_movie_title--rotate >>/dev/NULL One elif[" $"="Delta" ] A Then -/usr/local/coreseek-4.1/bin/indexer--config/usr/local/coreseek-4.1/etc/sphinx.conf delta_javzoo_movie_title--rotate >>/dev/NULL - elif[" $"="Merge" ] the Then -/usr/local/coreseek-4.1/bin/indexer--config/usr/local/coreseek-4.1/etc/sphinx.conf--merge main_javzoo_movie_title delta_javzoo_movie_title--rotate >>/dev/NULL - Else - EchoError action! +Exit1 - fi + AEnd_date= 'Date` at if["$?"-eq"0" ] - Then - EchoComplete @ $END _date - Else - Echoerror @ $END _date - fi in Echo
Usage
# Update all Indexes sh sphinx_index. SH all# Updating the primary index sh sphinx_index. SH main# Updating incremental indexes sh sphinx_index. SH delta# merging deltas and primary indexes sh sphinx_index. sh Merge
Note
Timing incremental updating and merging with Crond
Sphinx (Coreseek) installation and use guide