Scripted configuration

Manticore configuration supports shebang syntax, allowing the configuration to be written in a programming language and interpreted at loading. This enables dynamic settings, such as generating tables by querying a database table, modifying settings based on external factors, or including external files containing table and source declarations.

The configuration file is parsed by the declared interpreter, and the output is used as the actual configuration. This occurs each time the configuration is read, not only at searchd startup.

Note: This feature is not available on the Windows platform.

In the following example, PHP is used to create multiple tables with different names and to scan a specific folder for files containing extra table declarations:

#!/usr/bin/php
...
<?php for ($i=1; $i<=6; $i++) { ?>
table test_<?=$i?> {
  type = rt
  path = /var/lib/manticore/data/test_<?=$i?>
  rt_field = subject
  ...
 }
 <?php } ?>
 ...

 <?php
 $confd_folder='/etc/manticore.conf.d/';
 $files = scandir($confd_folder);
 foreach($files as $file)
 {
         if(($file == '.') || ($file =='..'))
         {} else {
                 $fp = new SplFileInfo($confd_folder.$file);
                 if('conf' == $fp->getExtension()){
                         include ($confd_folder.$file);
                 }
         }
 }
 ?>

Comments

Manticore Search's configuration file supports comments, which help provide explanations or notes within the configuration file. The # character is used to start a comment section. You can place the comment character either at the beginning of a line or inline within a line.

When using comments, be cautious when incorporating the # character in character tokenization settings, as everything following it will be ignored. To prevent this, use the # UTF-8 code, which is U+23.

If you need to use the # character within your configuration file, such as within database credentials in source declarations, you can escape it using a backslash \. This allows you to include the # character in your settings without it being interpreted as the start of a comment.

Inheritance of index and source declarations

Inheritance in index and source declarations enables better organization of tables with similar settings or structures and reduces the configuration size. Both parent and child tables or sources can utilize inheritance.

No specific configurations are needed for a parent table or source.

In the child table or source declaration, specify the table or source name followed by a colon (:) and the parent name:

table parent {
path = /var/lib/manticore/parent
...
}

table child:parent {
path = /var/lib/manticore/child
...
}

The child will inherit the entire configuration of the parent. Any settings declared in the child will overwrite the inherited values. Be aware that for multi-value settings, defining a single value in the child will clear all inherited values. For example, if the parent has several sql_query_pre declarations and the child has a single sql_query_pre declaration, all inherited sql_query_pre declarations are cleared. To override some of the inherited values from the parent, explicitly declare them in the child. This is also applicable if you don't need a value from the parent. For example, if the sql_query_pre value from the parent is not needed, declare the directive with an empty value in the child like sql_query_pre=.

Note that existing values of a multi-value setting will not be copied if the child declares one value for that setting.

The inheritance behavior applies to fields and attributes, not just table options. For example, if the parent has two integer attributes and the child needs a new integer attribute, the integer attribute declarations from the parent must be copied into the child configuration.