java.lang.Object
org.elasticsearch.xpack.core.template.TemplateUtils
Handling versioned templates for time-based indices in x-pack
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckTemplateExistsAndVersionIsGTECurrentVersion(String templateName, ClusterState state, long currentVersion) Checks if a versioned template exists, and if it exists checks if the version is greater than or equal to the current version.static StringloadTemplate(String resource, String version, String versionProperty) Loads a built-in template and returns its source.static StringLoads a built-in template and returns its source after replacing given variables.static StringreplaceVariable(String input, String variable, String value) Replaces all occurrences of given variable with the valuestatic StringreplaceVariables(String input, String version, String versionProperty, Map<String, String> variables) static voidParses and validates that the source is not empty.
-
Method Details
-
loadTemplate
Loads a built-in template and returns its source. -
loadTemplate
public static String loadTemplate(String resource, String version, String versionProperty, Map<String, String> variables) Loads a built-in template and returns its source after replacing given variables. -
validate
Parses and validates that the source is not empty. -
replaceVariables
-
replaceVariable
Replaces all occurrences of given variable with the value -
checkTemplateExistsAndVersionIsGTECurrentVersion
public static boolean checkTemplateExistsAndVersionIsGTECurrentVersion(String templateName, ClusterState state, long currentVersion) Checks if a versioned template exists, and if it exists checks if the version is greater than or equal to the current version.- Parameters:
templateName- Name of the index templatestate- Cluster statecurrentVersion- The current version to check against
-