Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Sphinx, a high performance SQL full-text search engine

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you the "high-performance SQL full-text search engine Sphinx how to use", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "high-performance SQL full-text search engine Sphinx how to use" this article.

Sphinx is a high-performance full-text search engine based on SQL, and the performance of Sphinx is one of the best among many full-text search engines. With Sphinx, we can complete more professional search functions than the database itself, and can have a lot of targeted performance optimization.

Characteristics of Sphinx

Fast index creation: an index of nearly 1 million records can be created in about 3 minutes, and the incremental index is used, and the index is rebuilt very quickly.

Lightning retrieval speed: although it is a large amount of 10 million pieces of data, the query speed is also more than milliseconds, with an average query speed of less than 0.1 seconds in 2-4G text.

Search API is designed for many scripting languages, such as PHP,Python,Perl,Ruby, so you can easily call Sphinx-related interfaces in most programming applications.

A storage engine plug-in has been designed for MySQL, so if you use Sphinx on MySQL, it's almost convenient.

Supports distributed search and scales system performance horizontally.

PHP+MySQL+Sphinx search engine architecture diagram

Install Sphinx in MySQL

There are two ways to install Sphinx on MySQL:

* this method is called by API. We can use the API function of PHP,Python,Perl,Ruby and other programming languages to query. In this way, there is no need to recompile MySQL, and there are few changes between modules, so it is relatively flexible.

The second method needs to recompile MySQL and compile Sphinx into MySQL as a plug-in, which makes fewer changes to the program and only needs to change the SQL statement, but only if your MySQL version is above 5.1.

The following are * installation methods:

# download * * stable version of wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz tar xzvf sphinx-0.9.9.tar.gz cd sphinx-0.9.9. / configure-- prefix=/usr/local/sphinx/-- with-mysql-- enable-id64 make make installSphinx Chinese word segmentation plug-in Coreseek installation

Note: the installation tutorial for coreseek comes from here. Here is the detailed process:

Install and upgrade autoconf

Because coreseek requires version 2.64 of autoconf, you need to upgrade autoconf, otherwise an error will be reported. Download autoconf-2.64.tar.bz2 from http://download.chinaunix.net/download.php?id=29328&ResourceID=648 and install it as follows:

Tar-jxvf autoconf-2.64.tar.bz2 cd autoconf-2.64. / configure make make install download coreseek

The new version of coreseek puts dictionaries and sphinx source programs in a package, so you only need to download the coreseek package.

Wget http://www.wapm.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz installs mmseg (dictionary used by coreseek) tar xzvf coreseek-3.2.14.tar.gz cd mmseg-3.2.14. / bootstrap # output warning information can be ignored, if error occurs, it needs to be resolved. / configure-- prefix=/usr/local/mmseg3 make & & make install cd. The warning information output by installing coreseek (sphinx) cd csft-3.2.14 sh buildconf.sh # can be ignored. / 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 make & & make install cd. Test mmseg word Segmentation and coreseek search

Note: you need to set the character set to zh_CN.UTF-8 in advance to ensure that the Chinese language is displayed correctly. It is also possible for my system character set to be en_US.UTF-8.

Cd testpack cat var/test/test.xml # should display Chinese / usr/local/mmseg3/bin/mmseg-d / usr/local/mmseg3/etc var/test/test.xml / usr/local/coreseek/bin/indexer-c etc/csft.conf-- all / usr/local/coreseek/bin/search-c etc/csft.conf network search correctly at this time should return words: 1. 'Network': 1 documents, 1 hits 2. 'search': 2 documents, 5 hits generate mmseg thesaurus and configuration files

The new version has been automatically generated.

These are all the contents of this article entitled "how to use Sphinx, a high-performance SQL full-text search engine". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report