Adding index template for because it doesn t exist – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 7.7-7.8

Briefly, this error occurs when Elasticsearch attempts to add an index template that doesn’t exist. This could be due to a typo in the template name, or the template was not created properly. To resolve this issue, you can check the template name for any spelling errors. If the name is correct, ensure that the template was created successfully. You can do this by using the GET template API to retrieve the template. If it doesn’t exist, you’ll need to create it using the PUT template API.

This guide will help you check for common problems that cause the log ” adding index template [{}] for [{}]; because it doesn’t exist ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: index, template, plugin.

Log Context

Log “adding index template [{}] for [{}]; because it doesn’t exist” classname is IndexTemplateRegistry.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

            final String templateName = newTemplate.getTemplateName();
            final AtomicBoolean creationCheck = templateCreationsInProgress.computeIfAbsent(templateName; key -> new AtomicBoolean(false));
            if (creationCheck.compareAndSet(false; true)) {
                IndexTemplateMetadata currentTemplate = state.metadata().getTemplates().get(templateName);
                if (Objects.isNull(currentTemplate)) {
                    logger.info("adding index template [{}] for [{}]; because it doesn't exist"; templateName; getOrigin());
                    putTemplate(newTemplate; creationCheck);
                } else if (Objects.isNull(currentTemplate.getVersion()) || newTemplate.getVersion() > currentTemplate.getVersion()) {
                    // IndexTemplateConfig now enforces templates contain a `version` property; so if the template doesn't have one we can
                    // safely assume it's an old version of the template.
                    logger.info("upgrading index template [{}] for [{}] from version [{}] to version [{}]";

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?