Scripted configuration

Manticore configuration supports shebang syntax, meaning that the configuration can be written in a programming language and interpreted at loading, allowing dynamic settings.

For example, tables can be generated by querying a database table, various settings can be modified depending on external factors or external files can be included (which contain tables and/sources).

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

This facility is not available on Windows platform.

In the following example, we are using PHP to create multiple tables with different name and we also scan a specific folder for file containing extra declarations of tables.

  1. #!/usr/bin/php
  2. ...
  3. <?php for ($i=1; $i<=6; $i++) { ?>
  4. table test_<?=$i?> {
  5. type = rt
  6. path = /var/lib/manticore/data/test_<?=$i?>
  7. rt_field = subject
  8. ...
  9. }
  10. <?php } ?>
  11. ...
  12. <?php
  13. $confd_folder='/etc/manticore.conf.d/';
  14. $files = scandir($confd_folder);
  15. foreach($files as $file)
  16. {
  17. if(($file == '.') || ($file =='..'))
  18. {} else {
  19. $fp = new SplFileInfo($confd_folder.$file);
  20. if('conf' == $fp->getExtension()){
  21. include ($confd_folder.$file);
  22. }
  23. }
  24. }
  25. ?>

Comments

The configuration file supports comments, with # character used as start comment section. The comment character can be present at the start of the line or inline.

Extra care should be considered when using # in character tokenization settings as everything after it will not be taken into consideration. To avoid this, use # UTF-8 which is U+23.

# can also be escaped using \. Escaping is required if # is present in database credential in source declarations.

Inheritance of index and source declarations

Both index and source declarations support inheritance. It allows a better organization of tables having similar settings or structure and reduces the size of the configuration.

For a parent table/source nothing needs to be specified.

For the child table/source the declaration will contain the table/source name followed by : and the parent name.

  1. table parent {
  2. path = /var/lib/manticore/parent
  3. ...
  4. }
  5. table child:parent {
  6. path = /var/lib/manticore/child
  7. ...
  8. }

The child will inherit the entire configuration of the parent. In the child declaration any setting declared will overwrite the inherited values. Please note that in case of multi-value settings, defining a single value in child will clear out all inherited values. For example in the parent there are several sql_query_pre declaration and the child has a single sql_query_pre declaration, all the sql_query_pre inherited declarations are cleared. If you need to override some of the inherited values from parent, they need to be explicitly declared in the child. This is also available if you don’t need a value from parent. For example if the value of sql_query_pre from parent is not needed, then in the child you can declare the directive with an empty value like sql_query_pre=. This also means 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 and not just table options. If, for example, the parent has 2 integer attributes and the child needs a new integer attribute, the integer attributes declaration from parent must be copied in the child configuration.