Scripting in config

Did you know that Sphinx and Manticore Search configs allow you to do scripting by using shebang syntax? Here is an example of how useful it can be in some cases:

Imagine you have 3 tables with identical structure that you would like to index into 3 indexes one per table. You can just make a php script which will do it and use it as a Manticore Search config instead of describing each source/index separately:

$source= "source [TABLE]_src {
  type      = mysql
  sql_host    = localhost
  sql_user    = user
  sql_pass    = password
  sql_db      = db
  sql_port    = 3306
  sql_query = SELECT [TABLE].id, title, body FROM [TABLE] WHERE [TABLE].id >=\$startand[TABLE].ID <=\$end
  sql_query_range = SELECT MIN(id), MAX(id) FROM [TABLE]
  sql_range_step = 1000
$index= "index [TABLE]_idx {
  source      = [TABLE]_src
  path      = /path/to/indexes/idx_[TABLE]
$tables= array('Cats', 'Dogs', 'Mouses');
foreach($tables as $table) {
  echo str_replace('[TABLE]', $table, $source)."\n";
  echo str_replace('[TABLE]', $table, $index)."\n";
searchd {
  listen          = localhost:9306:mysql41
  pid_file        = /path/to/

Now you can use this file just like a normal Manticore Search config:

[snikolaev@dev01 ~]$ searchd -c manticore.conf
Manticore 2.6.4 4510fa4@180501 dev
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (
Copyright (c) 2017-2018, Manticore Software LTD (

using config file 'manticore.conf'...


Leave a Reply


Personal and team training will maximize them performance. 

Custom development

Need cone custom or individual features?

Fill the form and don’t forget to make the description of what you need.

Free config review

There are often optimizations that can be made to a Sphinx / Manticore setup by changing some simple directives in the configuration or making quick changes to an index definition.

Some common mistakes and issues can include:

  • doing main+delta without kill-lists, even if the delta does include updated records found in the main
  • using wildcarding with very short prefix/infix which can hammer performance in some cases
  • disabled (unintentional) seamless rotates and getting stalls on index rotations
  • adding texts as string attributes even if they are not using for any kind of operation (filtering, grouping, sorting) or mandatory to be present in results
  • using deprecated settings 

Having a quick look on the configuration can show issues or potential issues, this is why we want to offer a gift to our growing community!

When uploading your configuration file, we recommend to remove any database credentials first.

We suggest also you give as many possible details about your setup: how big is the data you have, how typical queries look and what issues you experience.

Contact us