# DataType Changes after rollover of Index

**URL:** https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619
**Category:** Elasticsearch
**Created:** [September 5, 2020, 7:32am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619 "2020-09-05T07:32:45Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![tusharnemade](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tusharnemade](https://discuss.elastic.co/u/tusharnemade)
#### Post date: [September 5, 2020, 7:32am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/1 "2020-09-05T07:32:45Z")

</div>

Hi Team

I am using Elasticsearch Version 7.5.2.  
I have one index with grows in size and documents. Once it has reached 1000 documents , we are performing rollover.

Command :  
`curl -XPOST '10.10.10.1:9200/myevents/_rollover?pretty' -H 'Content-Type: application/json' -d '{ "conditions": { "max_docs": 1000}}'`

Index is having mapping with one field "starttime" having data type "date".

But after rollover new index is having data type as "long" for same field.

Does rollover changes mapping data type of original index ?

I am aware of specifying mapping in rollover command , would like to understand the rollover behaviour in here.

Can you please help me in understanding..

Thanks  
Tushar Nemade

---

<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: [September 6, 2020, 4:51am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/2 "2020-09-06T04:51:58Z")

</div>

What does your index template(s) look like?

---

<div class="post-metadata">

### Author: ![tusharnemade](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tusharnemade](https://discuss.elastic.co/u/tusharnemade)
#### Post date: [September 6, 2020, 7:20am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/3 "2020-09-06T07:20:37Z")

</div>

We do not use Index template..

---

<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: [September 6, 2020, 8:53am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/4 "2020-09-06T08:53:22Z")

</div>

If you do not use index template the type will be automatically mapped based on the first document encountered and can vary. I would recommend using an index template to control mappings for important fields.

---

<div class="post-metadata">

### Author: ![tusharnemade](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tusharnemade](https://discuss.elastic.co/u/tusharnemade)
#### Post date: [September 6, 2020, 9:06am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/5 "2020-09-06T09:06:29Z")

</div>

Okay.

So can we state below this is what would have happened.

1. Rollover condition met , Index is rollover to myevents-000002
2. After Rollover the first document came in, having field "startTime" was some value "epoch" , hence it made it as long data type. While the existing "myevents-000001" was having data type as "date".

---

<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: [September 6, 2020, 9:11am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/6 "2020-09-06T09:11:15Z")

</div>

Yes, epoch timestamps are not recognized as dates when dynamic mapping is used.

---

<div class="post-metadata">

### Author: ![tusharnemade](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tusharnemade](https://discuss.elastic.co/u/tusharnemade)
#### Post date: [September 6, 2020, 9:12am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/7 "2020-09-06T09:12:33Z")

</div>

Got it.

Thank You Christian , for your time and responses to the point. It help me in my understanding.

1. Rollover does not maintain mapping of existing index
2. EPOCH is not always "DATE" data type considered in mapping dynamically.

Thank You  
Tushar Nemade

---

<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: [September 6, 2020, 9:15am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/8 "2020-09-06T09:15:58Z")

</div>

> [@tusharnemade](#):
>
> Rollover does not maintain mapping of existing index

No, this is exactly what index templates are for.

> [@tusharnemade](#):
>
> EPOCH is not always "DATE" data type considered in mapping dynamically.

Epoch is NEVER dynamically mapped as a date as it does not pass [date detection](https://www.elastic.co/guide/en/elasticsearch/reference/7.9/dynamic-field-mapping.html#date-detection).

---

<div class="post-metadata">

### Author: ![tusharnemade](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tusharnemade](https://discuss.elastic.co/u/tusharnemade)
#### Post date: [September 6, 2020, 9:18am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/9 "2020-09-06T09:18:02Z")

</div>

Thank You very much...

---

<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: [September 6, 2020, 9:19am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/10 "2020-09-06T09:19:56Z")

</div>

If you look in [the docs](https://www.elastic.co/guide/en/elasticsearch/reference/7.9/getting-started-index-lifecycle-management.html) it includes creating an index template in the steps described.

---

<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: [October 4, 2020, 9:20am UTC](https://discuss.elastic.co/t/datatype-changes-after-rollover-of-index/247619/11 "2020-10-04T09:20:13Z")

</div>

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