# Uptades to template not being applied

**URL:** <https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606>\
**Category:** Elasticsearch\
**Created:** [September 30, 2022, 8:45pm UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606 "2022-09-30T20:45:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![somatusjn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/somatusjn/32/111569_2.png) [@somatusjn](https://discuss.elastic.co/u/somatusjn)\
**Post date:** [September 30, 2022, 8:45pm UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/1 "2022-09-30T20:45:10Z")

</div>

I'm getting an error when trying to post a document. The error I think is that the format I used for a date property is incorrect. I initially used YYYY-MM-DD'T'hh:mm:ssZ, but since then I have made like 10 calls to update the template, and deleted the template and created it again to have a format of yyyy-MM-dd'T'HH:mm:ssZ. But the problem is that no matter what I do to update the template, when I try to post a document, elastic is still using the initial format I used. I can see it in the error message I get.

When I make the call to get all templates, I see that the template has the right format. So why is elastic still using the original format I used? What can I do to apply the new format?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 30, 2022, 11:18pm UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/2 "2022-09-30T23:18:23Z")

</div>

Hi @somatusjn Welcome to the community .

You're going to need to provide your template and a sample command that posts document to the index so we can check.

Most likely your document is not matching the index pattern in the template or there's another template that you're not aware of.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [October 1, 2022, 12:44am UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/3 "2022-10-01T00:44:57Z")

</div>

> [@somatusjn](#):
>
> So why is elastic still using the original format I used? What can I do to apply the new format?

Did you also recreated the index with a name that matches the `index_pattern`?

As asked, you need to share your template and a sample of the document and also check if there is another template that could match the same `index_pattern` and override it.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 1, 2022, 5:05am UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/4 "2022-10-01T05:05:47Z")

</div>

Templates are applied when indices are created. Any changes made to templates will not affect existing indices where fields have already been mapped.

---

<div class="post-metadata">

**Author:** ![somatusjn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/somatusjn/32/111569_2.png) [@somatusjn](https://discuss.elastic.co/u/somatusjn)\
**Post date:** [October 6, 2022, 4:46pm UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/5 "2022-10-06T16:46:07Z")

</div>

The template is too big to share, but I fetched all the templates in our cluster by calling /\_template. There are only two templates that we created. The rest seem to be default templates that elastic uses. One template has pattern:

"index\_patterns": [  
"transcription\_documents\_\*"  
],

the other has:

"index\_patterns": [  
"transcription\_logs\_\*"  
],

I updated the template for "transcription\_documents\_\*". I can see the right format when I fetched the templates. When I post documents to that index, I use:

es\_url = f"{es\_endpoint}/transcription\_documents\_{today\_str}/\_doc"

And I get the error that a property in the template is still using the old format I created:

Old format:

"blob\_created": {  
"format": "YYYY-MM-DD'T'hh:mm:ssZ",  
"type": "date"  
}

new format:

"blob\_created": {  
"format": "yyyy-MM-dd'T'HH:mm:ssZ||yyyy-MM-dd'T'HH:mm:ss'Z'",  
"type": "date"  
}

error:

"reason":"failed to parse date field [2022-07-06T23:32:21Z] with format [YYYY-MM-DD'T'hh:mm:ssZ]"

I'm at a loss. Any help will be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 6, 2022, 4:49pm UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/6 "2022-10-06T16:49:41Z")

</div>

Has a new index been created since you updated the index template? Does the mapping for the field in this differ compared to earlier indices?

---

<div class="post-metadata">

**Author:** ![somatusjn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/somatusjn/32/111569_2.png) [@somatusjn](https://discuss.elastic.co/u/somatusjn)\
**Post date:** [October 6, 2022, 4:52pm UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/7 "2022-10-06T16:52:28Z")

</div>

Actually, this is brand new cluster. There are no documents or indices with that pattern. I called:

/transcription\_documents\_\*/\_search?pretty=true

And I get:  
{  
"took": 2,  
"timed\_out": false,  
"\_shards": {  
"total": 1,  
"successful": 1,  
"skipped": 0,  
"failed": 0  
},  
"hits": {  
"total": {  
"value": 0,  
"relation": "eq"  
},  
"max\_score": null,  
"hits":   
}  
}

I can't input any docs because of that issue.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [October 6, 2022, 5:46pm UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/8 "2022-10-06T17:46:31Z")

</div>

But that means the mapping is already defined!

What does this show

`GET /transcription_documents_{today_str}/`

looks for that `"blob_created"`

Changing the template does not change the mapping.. if the index is already created... which it appears to be

Also what does  
`GET _cat/indices/transcription_documents_*/?v`

Delete the index and try again.

---

<div class="post-metadata">

**Author:** ![somatusjn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/somatusjn/32/111569_2.png) [@somatusjn](https://discuss.elastic.co/u/somatusjn)\
**Post date:** [October 6, 2022, 5:57pm UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/9 "2022-10-06T17:57:37Z")

</div>

Yeah I found the issue. It looks like although the documents fail to be indexed, for whatever reason an index transcription\_documents\_20221006 is still created. I got that by calling /\_cat/indices. So I guess any document that tries to be indexed with that index uses the format that was used for that index that failed. So I had to run DELETE /transcription\_documents\_20221006 and that worked.

---

<div class="post-metadata">

**Author:** ![somatusjn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/somatusjn/32/111569_2.png) [@somatusjn](https://discuss.elastic.co/u/somatusjn)\
**Post date:** [October 6, 2022, 6:25pm UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/10 "2022-10-06T18:25:41Z")

</div>

I just read what you wrote. That was the solution. Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 3, 2022, 6:26pm UTC](https://discuss.elastic.co/t/uptades-to-template-not-being-applied/315606/11 "2022-11-03T18:26:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
