Sphinx (SQL Phrase Index) is a full-text search system with support for the morphology of various languages. Allows you to quickly and flexibly search for information in the database using free text.
To order Sphinx, do the following:
To use Sphinx on a site, you need to configure both Sphinx itself and the site.
After ordering Sphinx, two tabs appear on the page of this additional service:
The configuration consists of two sections:
source
) - configuration of the data source and its name (in the example db_source
):type
) - data source type (in the example mysql
).sql_host
, sql_port
, sql_user
, sql_pass
, sql_db
) — data to connect to MySQL databasewhere the information for indexing will come from.sql_query_pre
) - a request that will be before the main request for receiving data from the database (in the example SET NAMES utf8
- setting UTF-8 encoding).sql_query
) - a request to get the necessary data from the database for indexing (in the example select id, title, content from table
- columns id
, title
and content
from the table table
).index
) - the configuration of the index and its name (in the example test_index
):source
) - the name of the data source, where the information for indexing will come from (in the example db_source
- see above).path
) - the absolute path to the file with indices (in the example /home/example/.system/sphinx/test_index
).morphology
) - the name of the library (in the example stem_ru
), which will be used to search for a word with different word forms - for example, by the query “dog"Will return results with options"dogs», «dog», «dogs" etc.index_exact_words
) - when used in conjunction with the directive expand_keywords
allows you to return more relevant results on request (in the example 1
- included).min_word_len
) - used by default 1
, but words of this length usually do not carry a semantic load (in the example 3
).A detailed description of the operation of Sphinx and a list of all its parameters can be found in official documentation (English).
Below you can:
After clicking "Save configuration»:
Columns:
Before using plugins to work with Sphinx, carefully read their requirements and compatibility. Most plugins have not been supported for a long time and work with Sphinx version 2.2 or lower, the hosting uses version 3.
Setting up a site to work with Sphinx is in the competence of the site developer or involved third-party specialists.
The task is reduced to the following stages:
The site connects to Sphinx over a socket. The socket path can be found on the Sphinx control page. The port should be specified depending on the configuration of the plug-in being connected; in general, the port can be neglected by specifying it as 0 or 9312.
To view the Sphinx log do the following:
cat ~/.system/sphinx/searchd.log
tail -f ~/.system/sphinx/searchd.log