Before you can get Sphinx working with the Sphinx Storage Engine on MariaDB, you need to configure it.

  • The default configuration file is called sphinx.conf, usually located in /etc/sphinxsearch (Debian/Ubuntu), /etc/sphinx/sphinx.conf. (Red Hat/CentOS) or C:\Sphinx\sphinx.conf (Windows).

If it doesn't already exist, you can use the sample configuration file, sphinx.conf.dist. There is also sample data supplied that we can use for testing. Load the sample data (which creates two tables, documents and tags in the test database), for example:

mysql -u test < /usr/local/sphinx/etc/example.sql (Red Hat, CentOS) mysql -u test < /usr/share/doc/sphinxsearch/example-conf/example.sql (Debian/Ubuntu)

The sample configuration file documents the available options. You will need to make at least a few changes. A MariaDB user with permission to access the database must be created. For example:

CREATE USER 'sphinx'@localhost 
  IDENTIFIED BY 'sphinx_password';
GRANT SELECT on test.* to 'sphinx'@localhost;

Add these details to the mysql section of the config file:

sql_host = localhost 
sql_user = sphinx 
sql_pass = sphinx_password 
sql_db   = test 
sql_port = 3306 

On Windows, the path and pid lines will need to be changed to reflect a valid path, usually as follows:

path = C:\Sphinx\docsidx
pid_file = C:\Sphinx\

The query in the configuration files is the query that will be used for building the index. In the sample data, this is:

sql_query = \
  SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content \
  FROM documents


Comments loading...