Coreseek installation and usage

Source: Internet
Author: User

Coreseek installation and use

Generally, websites require the search function. For php + mysql sites, coreseek is recommended. For java sites, lucene is recommended. coreseek is a good full-text search software, supports high-speed indexing, strong scalability, distributed retrieval, and different search modes ('Exact match', 'phrase match', or 'any match ').

Logo1


If you encounter any problems in the following process, refer to the errors and solutions encountered during coreseek installation. I will summarize the common problems and solutions encountered during installation and configuration.

1. coreseek installation

1: install the mmseg Dictionary

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 # configure the installation directory
Make
Make install
Cd ..

2: install coreseek


Cd csft-3.2.14
Sh buildconf. sh
. /Configure -- prefix =/usr/local/coreseek -- without-unixodbc -- with-mmseg-separated des =/usr/local/mmseg3/include/mmseg/--- mmseg-libs =/usr/local/mmseg3/lib/-- with-mysql =/usr/local/mysql
Make
Make install
Cd ..

3: Test mmseg word segmentation and coreseek search


Cd/usr/local/src/coreseek-3.2.14
Cd testpack
Cat var/test. xml # What is actually Chinese content
/Usr/local/mmseg3/bin/mmseg-d/usr/local/mmseg3/etc var/test. xml # display xml file content
/Usr/local/coreseek/bin/indexer-c etc/csft. conf -- all # create an index
/Usr/local/coreseek/bin/search-c etc/csft. conf # search

II. Configure and use coreseek

1: configure the example. conf file


Cd/usr/local/coreseek/etc
Cp sphinx-min.conf.dist (example. conf)

Modify the configuration of example. conf to 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 # no matter what the table's primary key is, the result is the id
SQL _query_info_pre = SET NAMES utf8 # SET the correct character SET during command line query
SQL _query_info = SELECT * FROM table WHERE id = $ id LIMIT 100 # read original data FROM the database during command line query
}

# Index definition
Index example
{
Source = example # corresponding source name
Path =/usr/local/coreseek/var/data/example/# change it to the actual absolute path
Docinfo = extern
Mlock = 0
Morphology = none
Min_word_len = 1
Html_strip = 0

# Chinese word segmentation configuration, for details, see: http://www.coreseek.cn/products-install/coreseek_mmseg/
Charset_dictpath =/usr/local/mmseg3/etc/# BSD, set in Linux,/end of symbol
# Charset_dictpath = etc/# set in Windows, and end with a/symbol. It is best to provide an absolute path,
Charset_type = zh_cn.utf-8
}


# Global index definition
Indexer
{
Mem_limit = 128 M
}

# Searchd service definition
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 # change it to the actual absolute path, for example,/usr/local/coreseek/var /...
Log =/usr/local/coreseek/var/log/searchd_example.log # change it to the actual absolute path, for example,/usr/local/coreseek/var /...
Query_log =/usr/local/coreseek/var/log/query_example.log # change it to the actual absolute path, for example,/usr/local/coreseek/var /...
}

2: Start the searchd service (this is important)

After coreseek is installed, the searchd service is not enabled and needs to be enabled first. Otherwise, an error occurs during index creation.

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 prompt is displayed:

Coreseek Fulltext 3.2 [sph00000.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 ).
It indicates that coreseek is ready for use.
You can write the index creation command into crontab for timing and real-time index update.

4: php and coreseek combined for query

Download sphinxapi first, and then introduce the file to query with php. For more details and configurations of the following parameters, refer to coreseek api php Manual.

 

Require_once ('sphinxapi ');
$ S = new SphinxClient ();
$ S-> SetServer ('192. 0.0.1 ', '123'); // Set the host name and TCP port of searchd.
$ S-> SetConnectTimeout (1); // sets the connection timeout.
$ S-> SetMatchMode (SPH_MATCH_BOOLEAN); // you can specify the full-text query matching mode.
$ Page_size = 20; // custom page number
$ S-> SetLimits ($ start, $ page_size); // you can specify the offset and number of returned result sets.
$ S-> SetSortMode (SPH_SORT_EXTENDED, "good_count DESC, @ id DESC"); // Set sorting
$ S-> SetArrayResult (true); // control the return format of the search result set
$ Res = $ s-> Query ($ keyword, '*'); // execute the search Query
$ Res_list = $ res ['matches'];


Installation errors and solutions


1. Test mmseg word segmentation

Run

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

The following error is prompted:

/Usr/local/coreseek/bin/indexer: error while loading shared libraries: libmysqlclient. so.18: cannot open shared object file: No such file or directory

Cause: The dependency Library ibmysqlclient. so.18 of sphsf-indexer cannot be found.

Solution:

Vi/etc/ld. so. conf
Add/usr/local/mysql/lib

Then run ldconfig

Problem solving

2. When performing an index

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

The following error is prompted:


FATAL: failed to open/usr/local/coreseek/var/data/ttd_article/. tmp. spl: No such file or directory, will not index. Try -- rotate option.

Cause: mysql. sock cannot be found in the source.

Solution: add the following code to the source of the configuration file csft_ttd_search.conf (a self-created file).

SQL _sock =/tmp/mysql. sock

3. The index is not created successfully due to a warning when the index is executed.


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 cannot be found.

Solution: create the searchd_ttd_search.pid file in '/usr/local/coreseek/var/log'.

Run/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/csft_ttd_search.conf-all-rotate.
Another warning is reported:


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 is created, no process id is written to the file.

Solution (Root Cause): The searchd service is not started before the index is executed. Therefore, run the following command:

/Usr/local/coreseek/bin/searchd -- config/usr/local/coreseek/etc/ttd_search.conf

The long-awaited success prompt is displayed:


Coreseek Fulltext 3.2 [sph00000.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.