Sphinx Full-Text search engine installation and configuration

Source: Internet
Author: User

Sphinx Full-Text search engine

Installation and configuration of Sphinx

---------------------------------------------------------------------------------------------

SQL Structured Query Language (is a standard, all relational database mysql,sqlserver,oracle)

There are two ways to use Sphinx:

First: Use the Sphinx API to manipulate Sphinx (common)
Sphinx can use the API class, or you can compile the API into PHP as an extension
The second type: the Sphinx storage engine using MySQL


Sphinx This is the full-text search engine in English

Coreseek This is a full-text search engine that supports Chinese thesaurus


Difference:
How can an English article distinguish between a word with a space and a word
Chinese article I love Beijing Tian ' an Chinese word library


Steps to use Sphinx:

1. Installation
CD E:/usr/local/coreseek-3.2.14-win32
2. Configuration (config file csft_mysql.conf)
Configuration file format
1, data source definition (point to the source of your data, usually MySQL)
2, index (some configuration information of the index)
3, indexer (internal memory---Basic does not need to set)
4, Searchd (some configuration of the server---)
Attention:
1, a configuration file can be configured multiple data sources and indexes ((), (), nnnn)
2. Sql_query main query (which fields in the database table are queried-depending on your page's search criteria)
Select first field (must be primary key)

3. Indexer.exe-c configuration file--all (parameter--all means create all indexes)
. \bin\indexer.exe-C. \etc\csft_mysql.conf--all
4. Start Searchd Service searchd.exe-c configuration file
. \bin\searchd.exe-c. \etc\csft_mysql.conf
5, PHP operation Sphinx

------------------------------------------------------------------------------------------

How the Sphinx search engine is referenced in the YII framework

Install the test first, I don't need to say more!

Configure the database by configuring the csft_mysql.conf configuration file below


Create a folder under the Vendor directory Sphinx and then put sphinxapi.php in the folder
Any one of the public file's configuration files (for example: bootstrap.php) writes the following sentence

or write to the top or method of the controller that is going to use the Sphinx.
YII:: $classMap [' sphinxclient ']= "@vendor/sphinx/sphinxapi.php";

Write a namespace on the top level of the controller
Use sphinxclient;


Instantiating an object in a controlled way
Such as:
$CL = new Sphinxclient ();

$cl->setserver (' 127.0.0.1 ', 9312);
$CL->setconnecttimeout (3);

$cl->setarrayresult (TRUE);
$CL->setmatchmode (Sph_match_any);

$res = $cl->query (' foreign ', ' * ');

Print_r ($CL);

Print_r ($res);

Then find the ID of the index, using the ID found to query the database about the search data

The data is uploaded into the views view and traversed, which is the simple application of Sphinx in Yii framework.

Sphinx Full-Text search engine installation and configuration

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.