Class IndexTemplateConfig

java.lang.Object
org.elasticsearch.xpack.core.template.IndexTemplateConfig

public class IndexTemplateConfig extends Object
Describes an index template to be loaded from a resource file for use with an IndexTemplateRegistry.
  • Constructor Details

    • IndexTemplateConfig

      public IndexTemplateConfig(String templateName, String fileName, int version, String versionProperty)
      Describes a template to be loaded from a resource file. Includes handling for substituting a version property into the template. The versionProperty parameter will be used to substitute the value of version into the template. For example, this template: {"myTemplateVersion": "${my.version.property}"} With version = "42"; versionProperty = "my.version.property" will result in {"myTemplateVersion": "42"}. Note that this code does not automatically insert the version index template property - include that in the JSON file defining the template, preferably using the version variable provided to this constructor.
      Parameters:
      templateName - The name that will be used for the index template. Literal, include the version in this string if it should be used.
      fileName - The filename the template should be loaded from. Literal, should include leading / and extension if necessary.
      version - The version of the template. Substituted for versionProperty as described above.
      versionProperty - The property that will be replaced with the version string as described above.
    • IndexTemplateConfig

      public IndexTemplateConfig(String templateName, String fileName, int version, String versionProperty, Map<String,String> variables)
      Describes a template to be loaded from a resource file. Includes handling for substituting a version property into the template. The versionProperty parameter will be used to substitute the value of version into the template. For example, this template: {"myTemplateVersion": "${my.version.property}"} With version = "42"; versionProperty = "my.version.property" will result in {"myTemplateVersion": "42"}.
      Parameters:
      templateName - The name that will be used for the index template. Literal, include the version in this string if it should be used.
      fileName - The filename the template should be loaded from. Literal, should include leading / and extension if necessary.
      version - The version of the template. Substituted for versionProperty as described above.
      versionProperty - The property that will be replaced with the version string as described above.
      variables - A map of additional variable substitutions. The map's keys are the variable names. The corresponding values will replace the variable names.
  • Method Details

    • getFileName

      public String getFileName()
    • getTemplateName

      public String getTemplateName()
    • getVersion

      public int getVersion()
    • loadBytes

      public byte[] loadBytes()
      Loads the template from disk as a UTF-8 byte array.
      Returns:
      The template as a UTF-8 byte array.