Linux Coreseek installation and use of the detailed method

Source: Internet
Author: User

General site need search function, if it is Php+mysql site, recommend the choice of Coreseek, if the Java site is recommended to use Lucene,coreseek is a very good Chinese full-text search/search software, support high-speed indexing, have a strong scalability, support distributed search To support different search modes (' exact match ', ' phrase match ', ' any match ').

First, Coreseek installation

1: The installation of MMSEG Word Library

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 example.conf files

Cd/usr/local/coreseek/etc
CP Sphinx-min.conf.dist example.conf

Transform the configuration of the example.conf into the configuration files 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 #不管表的主键叫什么, detected results are ID
Sql_query_info_pre = set NAMES UTF8 #命令行查询时, setting the correct character set
Sql_query_info = The SELECT * from table where id= $id LIMIT to read raw data from the database when 100# command line query
}

#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 #中文分词配置, please see: http://www.coreseek.cn/products-install/coreseek_mmseg/
Charset_dictpath =/usr/local/mmseg3/etc/#BSD, Linux environment settings,/end of symbol
#charset_dictpath = etc/#Windows环境下设置,/symbol end, best given 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 the Searchd service (this is very important)

Coreseek just installed after the SEARCHD service is not open, you need to open first, or create an index when there will be errors.

First 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 prompts appear:

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).
Indicates that Coreseek is ready for use.
The command to create an index can be written to the crontab inside for a timed, updated index in real time.

4:php and Coreseek together for query

Download the Sphinxapi first, and then the file introduced in combination with PHP query, the following more details and configuration of parameters, you can refer to the Coreseek API PHP manual

Require_once (' Sphinxapi ');
$s = new sphinxclient ();
$s->setserver (' 127.0.0.1 ', ' 9312 '); Set SEARCHD host name and TCP port
$s->setconnecttimeout (1); Setting the connection timeout
$s->setmatchmode (sph_match_boolean); Set up a matching pattern for full-text queries
$page _size=20;//The number of pages you define
$s->setlimits ($start, $page _size); Sets 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, ' * '),//Execute search query
$res _list = $res [' matches '];

Coreseek installation encountered errors and problem solutions

1, the test mmseg participle time

Perform


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


Prompts 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


Reason: Sphinx Indexer's dependent library ibmysqlclient.so.18 not found.

Solution:
Vi/etc/ld.so.conf
Join/usr/local/mysql/lib
Then run Ldconfig
Problem solving

2, the time to perform the index


/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/csft_ttd_search.conf--all--rotate


Prompts 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.
Reason: Source could not find Mysql.sock

Workaround: Add the following code to the source of the configuration file csft_ttd_search.conf (the file you created)

Sql_sock =/tmp/mysql.sock

3, the implementation of the index, the warning occurred, resulting in the index did not create a successful

warning:failed to open pid_file '/usr/local/coreseek/var/log/searchd_ttd_search.pid '.
Warning:indices not rotated.
Reason: Searchd_ttd_search.pid file not 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
Another warning appears:


warning:failed to scanf pid from Pid_file '/usr/local/coreseek/var/log/searchd_ttd_search.pid '.
Warning:indices not rotated.

Reason: Although the Searchd_ttd_search.pid file was created, there is no process ID written inside

Workaround (Root cause): The SEARCHD service is not started before the index is 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

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.