Sphinx Tutorial 2__ installation, configuration and use _ Search engine

Source: Internet
Author: User
Tags mysql client

The following is reproduced content, this test uses the sphinx2.2.10 version, basically no problem, in addition to the red font part.


Download Sphinx source package from Sphinx website, I am using sphinx2.1.6 one, install

The steps are as follows:

In any directory, unzip the Sphinx source package:

$ tar xzvf sphinx-2.1.6.tar.gz
$ CD Sphinx

To run the Configure Configuration program:

$./configure [Options]

Parameter configuration when specified, mainly as follows:

--prefix, specifies the location where the Sphinx is installed to the system; such as--prefix=/usr/local/sphinx
--with-mysql, MySQL installation directory, specify what directory to look for if a MySQL-related library file is automatically detected after failure
--with-pgsql, ditto, just for Pgsql.
Configuration example:./configure--prefix=/usr/local/sphinx--with-mysql=/usr/local/mysql

Additional configuration parameters:





$ make
In this step, you may encounter a problem, is reported Sphinx undefined reference to ' Libiconv ' error, the solution is to modify/src/makefile (note is the makefile under SRC is not csft under the makefile), edit libs =-lm-lexpat After adding-liconv, the line will be:
LIBS =-lm-lexpat-liconv-l/usr/local/lib

$ make Install
If no errors are generated in the compilation, this step should not encounter problems. If it is not installed properly after completion, go back to the error encountered in the make process.
Two. Configure and start the Sphinx Service 1, write the configuration file (after installation in the/usr/local/sphinx/etc/directory has a sphinx.conf.dist file, directly to the file name shpinx.conf on the line)
Modify the database information in your MySQL server information, and do not forget to modify the corresponding table name prefix.

2, import test data,

Enter Mysql> Source/usr/local/sphinx/etc/example.sql

3. Generate Index File

If the index build succeeds, the corresponding index file is generated under/usr/local/sphinx/var/data

4, Start Sphinx Search Service


The default Shpinx will be on port 9312, 93,062 ports, where 9312 port is the Shpinx protocol, this port needs to go through the API, Shpinx from the search client, MySQL shpinxse engine to access, And 9306 to go is the MYSQL41 protocol, this port can be directly through the MySQL client connection, and then the relevant search query

Third, search query

1, through the Sphinx from the search (in the bin/directory) can be searched at the command line:
./bin/search-c sphinx.conf Test

After running, the system prompts for a heap of information:
1. ' Test ': Documents, 123 hits
This means that there are 36 records in the library that meet the requirements, and there are 123 of the test.

(sphinx2.2.10 version, no search file)

2, through the Shpinx API access

There is an API folder in the downloaded Shpinx source directory, which provides examples of PHP, Java, Ruby, Python access to Sphinx searches via APIs

PHP test.php test will identify the data that contains the test keyword


PHP also has a corresponding Shpinx extension

3, through the MYSQL41 protocol access


The specific Query method reference http://sphinxsearch.com/docs/2.1.7/sphinxql-reference.html

4, in MySQL through the Shpinx engine access

MySQL Shpinx engine plug-in installation reference to my other article: http://blog.csdn.net/clh604/article/details/34101313

Sphinx The writing of the query statement please read Shpinx Official document: http://sphinxsearch.com/docs/2.1.7/sphinxse-using.html

Now I need to be indexed by the data below (is the Shpinx after the installation of the test data, the index configuration is also shpinx to the default---the default is for this test data)

Then create the Shpinx Engine Index table:
Weight INTEGER not NULL,
Query VARCHAR (3072) not NULL,
group_id INTEGER,
INDEX (query)
) Engine=sphinx connection= "Sphinx://";


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.