One, what is Sphinx
Sphinx is the abbreviation for SQL Phrase index (query phrase index), Sphinx is a full-text search engine based on SQL
Sphinx Full-text Search Engine
Coreseek support for Chinese full-text search engine
The mechanism of 1.sphinx consists of two parts: Generating index +search Index
2.sphinx index Type: Normal index +RT real time index + distributed index
Ii. advantages and disadvantages of Sphinx
Advantages: 1. High-speed indexing (on contemporary CPUs, up to 10mb/seconds)
2. High-Performance search
3, can handle massive data
4, provides the excellent correlation algorithm, based on the phrase similarity and the statistical BM2 compound ranking method
5. Support Distributed Search
6. Provide document fragment (summary and highlight) generation function
7, can be used as a MySQL storage engine to provide search services
8, support Boolean, phrase, word similarity and so on a variety of search patterns
9, the document supports multiple Full-text search fields (max no more than 32)
Disadvantages: 1, must have a primary key 2, the primary key must be integral type 3, not responsible for data storage 4, configuration is not flexible
Three, MySQL and Sphinx full text Search difference:
1, he can provide more professional than the database search function, making the application easier to achieve professional full-text search
2, he is a separate server, with a lot of MySQL itself does not have the expansion function, higher performance, he exists in MySQL before, better ease the pressure of the database.
Fundamentally, all of our operations revolve around the database, which means we have to minimize the pressure on the database through various methods and means.
Four, the Sphinx application scene
Whether the site or the app many product design ideas and product features more or less have similarities, then this side mainly tells the following several scenes
A search for a description or topic
The main implementation of the idea is a full index + incremental indexing method, can be set when the task Fixed-point running index
Search for user Nicknames
Mainly realizes the idea is the real-time index + the distributed index way, the user due to Overmuch, therefore uses the real-time index the method to increase, the old data passes through the running script to reread again after writes.
Tips for search box associative words
The main idea is the way of distributed indexing, automatically associating other people have entered the word.
Tip:morphology = Stem_en will enable the extraction of English words. Search English will not be a single letter searched, will improve the Sphinx search English words when the efficiency. Five, the realization principle of sphinx.
Sphinx's entire workflow is indexer program to the database to extract data, segmentation of data, and then generate a single or multiple indexes according to the generated participle, and pass them to the SEARCHD program. The client can then search through API calls. Vi. Data Search Sphinx xunsearch
Xunsearch and Sphinx principle is slightly different, xunsearch of course when creating an index, in fact, he created a database of his own, if you use Xunsearch to search for data, he will not go to your MySQL database to search, Instead, it goes directly to its own database and returns the data, and Sphinx is not, Sphinx creates some index files (the index table), and then searches the data by Sphinx, first he goes to the index file to search for data, and then returns the data that is currently being traced ID (where ID is the primary key), then go to the MySQL data by ID to search for the data, and then return to the data.