Implementing Sphinx

By 15th November 2013January 30th, 2020No Comments

MageStack natively supports Sphinx, in order to take advantage of it, you need to do 2 things,

  1. Enable Sphinx for the vhost (contact a member of the support team to do this)
  2. Ensure that you have placed the Sphinx configuration files in the correct directory (see below)

Sphinx Configuration Details

Hostname:  sphinx1.i
Port:      9315

SphinxQL Configuration Details

Hostname:  sphinx1.i
Port:      9316

Sphinx configuration file locations

! Your configuration file is usually generated by your Extension, please refer to the extensions documentation for instructions on how to do this.

There are 3 main configuration files we observe when building a Sphinx core for your vhost

The following directory must exist (adjust to suit),


Then within that, the following configuration files are valid,


Once you have added/updated these files, we can (re-)build your Sphinx core.

Default Sphinx configuration

! This configuration should only be used if you are developing your own extension that utilizes Sphinx

If you haven't specified your own Sphinx configuration, we use the following defaults (as is used on the demo store on MageStack), the fields

source magento_examplecom {
  type = mysql
  sql_host = %%DBHOST%%
  sql_user = %%DBUSER%%
  sql_pass = %%DBPASS%%
  sql_db   = %%DBNAME%%
  sql_port = 3306
  sql_sock = /var/lib/mysql/mysql.sock
  sql_query_pre = SET NAMES utf8;
  sql_query     = SELECT CONCAT(product_id, store_id) AS id, catalogsearch_fulltext.* FROM catalogsearch_fulltext
  sql_attr_uint = product_id
  sql_attr_uint = store_id

index examplecom {
  source = magento_examplecom
  path = %%SPHINXDIR%%/sphinx.index
  morphology   = stem_en, metaphone
  min_word_len = 1
  charset_type = utf-8
  blend_chars  = -
  blend_mode   = trim_both
  html_strip   = 1
  stopwords     = /microcloud/data/mysql/sphinx/examplecom/stopwords.txt
  exceptions    = /microcloud/data/mysql/sphinx/examplecom/synonyms.txt
  wordforms     = /microcloud/data/mysql/sphinx/examplecom/wordforms.txt

Using Variables in Configuration file

There are a number of pre-defined variables so that you can use to make management easier, they should be wrapped in %% characters as shown:

  • %%DBHOST%% - The database host (as stored in your local.xml)
  • %%DBNAME%% - The database name (as stored in your local.xml)
  • %%DBUSER%% - The database username (as stored in your local.xml)
  • %%DBPASS%% - The database password (as stored in your local.xml)
  • %%CLEANTLD%% - This is the vhost domain name, with all non a-zA-Z0-9 characters removed (Eg. examplecom)
  • %%INDEX_NAME%% - Same as the CLEANTLD variable
  • %%GROUP%% - The domain group name (eg. example)
  • %%TLD%% - The vhost top level domain, as defined in its directory path (eg.
  • %%SPHINXDIR%% - This is the path to the Sphinx index, it is automatically populated based on the index name (eg. examplecom)