Coreseek Installation and use
General site All need search function, if is Php+mysql site, suggest choose Coreseek, if is Java site recommended use Lucene,coreseek is a very good Chinese full-text search/search software, support high-speed indexing, strong extensibility, support distributed retrieval , support for different search modes (' exact match ', ' phrase match ', ' any match ').
Logo1
If you experience problems with the following procedures, refer to the error and problem solutions encountered by the Coreseek installation I have summarized the common problems and solutions encountered in the installation and configuration.
First, Coreseek installation
1: Install the mmseg Word store
wget http://www.coreseek.cn/uploads/csft/4.0/coreseek-3.2.14-beta.tar.gz
TAR-ZXVF coreseek-3.2.14-beta.tar.gz
CD Coreseek-3.2.14-beta
CD mmseg-3.2.14
./bootstrap
./configure--prefix=/usr/local/mmseg3 #配置安装目录
Make
Make install
Cd..
2: Install Coreseek
CD csft-3.2.14
SH buildconf.sh
./configure--prefix=/usr/local/coreseek--without-unixodbc--with-mmseg--with-mmseg-includes=/usr/local/mmseg3/ include/mmseg/--with-mmseg-libs=/usr/local/mmseg3/lib/--with-mysql=/usr/local/mysql
Make
Make install
Cd..
3: Test mmseg participle and coreseek search
cd/usr/local/src/coreseek-3.2.14
CD Testpack
Cat Var/test/test.xml #现实的是中文的内容
/usr/local/mmseg3/bin/mmseg-d/usr/local/mmseg3/etc Var/test/test.xml #显示xml文件内容
/usr/local/coreseek/bin/indexer-c etc/csft.conf--all #建立索引
/usr/local/coreseek/bin/search-c etc/csft.conf # to search
Second, coreseek configuration and use
1: Configure the example.conf file
Cd/usr/local/coreseek/etc
CP Sphinx-min.conf.dist example.conf
Transform the configuration of the example.conf into the configuration file we need.
SOURCE Example
{
Type = MySQL
Sql_host = localhost
Sql_user = * * *
Sql_pass = * * *
sql_db = * * *
Sql_port = 3306
Sql_sock =/tmp/mysql.sock
Sql_query_pre = SET NAMES UTF8
Sql_query = SELECT id,content from table_name #不管表的主键叫什么, the results are identified as ID
Sql_query_info_pre = set NAMES UTF8 #命令行查询时, setting the correct character sets
Sql_query_info = SELECT * FROM table WHERE id= $id LIMIT 100# command-line query, read raw data information from the database
}
#index定义
Index example
{
source = example #对应的source名称
path =/usr/local/coreseek/var /data/example/#请修改为实际使用的绝对路径
docinfo = extern
mlock = 0
morphology = None
min_word_len = 1
html_strip = 0
#中文分词配置, for more information, see: http://www.coreseek.cn/products-install/coreseek_mmseg/
Charset_dictpath =/usr/local/mmseg3/etc/#BSD, settings under Linux,/end of symbol
#charset_dictpath = etc/#Windows环境下设置,/end of symbol, best to give absolute path,
Charset_type = Zh_cn.utf-8
}
#全局index定义
Indexer
{
Mem_limit = 128M
}
#searchd服务定义
Searchd
{
Listen = 9312
Read_timeout = 5
Max_children = 60
max_matches = 1000
Seamless_rotate = 0
preopen_indexes = 0
Unlink_old = 1
Pid_file =/usr/local/coreseek/var/log/searchd_example.pid #请修改为实际使用的绝对路径, for example:/usr/local/coreseek/var/...
Log =/usr/local/coreseek/var/log/searchd_example.log #请修改为实际使用的绝对路径, for example:/usr/local/coreseek/var/...
Query_log =/usr/local/coreseek/var/log/query_example.log #请修改为实际使用的绝对路径, for example:/usr/local/coreseek/var/...
}
2: Open Searchd Service (this is important)
Coreseek just installed after the SEARCHD service is not open, you need to open, or create an index error.
Create a Searchd_example.pid file under/usr/local/src/coreseek/var/log, and then execute the following code:
/usr/local/coreseek/bin/searchd--config/usr/local/coreseek/etc/example.conf
3: Create an index
/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/example.conf--all--rotate
The following prompt appears:
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 '/usr/local/coreseek/etc/example.conf ' ...
Indexing index ' example ' ...
Collected 1 docs, 0.0 MB
Sorted 0.0 mhits, 100.0% done
Total 1 docs, 631 bytes
Total 0.005 sec, 118854 bytes/sec, 188.35 docs/sec
Total 1 Reads, 0.000 sec, 0.8 kb/call Avg, 0.0 msec/call avg
Total 5 writes, 0.000 sec, 0.5 kb/call avg, 0.0 msec/call avg
Rotating indices:succesfully sent SIGHUP to Searchd (pid=14094).
Note that the Coreseek is ready to use.
The command that creates the index can be written to crontab, and the index is updated in real time.
4:php and Coreseek combined for querying
First download Sphinxapi, then the file introduced in conjunction with PHP query, the following more parameters of the detailed and configuration, you can refer to the Coreseek API PHP manual
Require_once (' Sphinxapi ');
$s = new sphinxclient ();
$s->setserver (' 127.0.0.1 ', ' 9312 '); Set the host name and TCP port of the Searchd
$s->setconnecttimeout (1); Setting the connection timeout
$s->setmatchmode (sph_match_boolean); To set the matching pattern for full-text queries
$page _size=20;//The number of pages you define
$s->setlimits ($start, $page _size); Set the return result set offset and number
$s->setsortmode (sph_sort_extended, "Good_count desc, @id desc"); Set sort
$s->setarrayresult (true);//control the return format of the search result set
$res = $s->query ($keyword, ' * ');//Perform a search query
$res _list = $res [' matches '];
Installation of errors and problem-solving solutions
1, the test mmseg participle time
Perform
/usr/local/coreseek/bin/indexer-c etc/csft.conf--all
Prompt for the following error:
/usr/local/coreseek/bin/indexer:error while loading shared libraries:libmysqlclient.so.18:cannot open Shared object fi Le:no such file or directory
Cause: Sphinx Indexer's dependent library ibmysqlclient.so.18 not found.
Workaround:
Vi/etc/ld.so.conf
Join/usr/local/mysql/lib
Then run Ldconfig
Problem solving
2, when the index is executed
/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/csft_ttd_search.conf--all--rotate
Prompt for the following error:
Fatal:failed to open/usr/local/coreseek/var/data/ttd_article/.tmp.spl:no such file or directory, would not index. Try--rotate option.
Cause: Source sources could not find the Mysql.sock
Workaround: Add the following code to the source sources of the configuration file csft_ttd_search.conf (the file you created)
Sql_sock =/tmp/mysql.sock
3. When the index is executed, the warning appears, causing the index not to be created successfully
warning:failed to open pid_file '/usr/local/coreseek/var/log/searchd_ttd_search.pid '.
Warning:indices not rotated.
Cause: The Searchd_ttd_search.pid file could not be found
Workaround: Create a searchd_ttd_search.pid file under '/usr/local/coreseek/var/log '
Re-execute/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/csft_ttd_search.conf–all–rotate
There was another warning:
warning:failed to scanf pid from Pid_file '/usr/local/coreseek/var/log/searchd_ttd_search.pid '.
Warning:indices not rotated.
Cause: Although the Searchd_ttd_search.pid file was created, there is no write process ID in it
Workaround (Root cause): The SEARCHD service was not started before the index was executed, so execute the following command
/usr/local/coreseek/bin/searchd--config/usr/local/coreseek/etc/ttd_search.conf
There have been long-awaited success tips:
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 '/usr/local/coreseek/etc/ttd_search.conf ' ...
Listening on all interfaces, port=9312
Rotating index ' MySQL ': success
Coreseek installation and use of the method detailed