# Refuse field type change in mapping

**URL:** <https://discuss.elastic.co/t/refuse-field-type-change-in-mapping/173059>\
**Category:** Elasticsearch\
**Created:** [March 19, 2019, 10:44pm UTC](https://discuss.elastic.co/t/refuse-field-type-change-in-mapping/173059 "2019-03-19T22:44:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mortenb123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mortenb123/32/37227_2.png) [@mortenb123](https://discuss.elastic.co/u/mortenb123)\
**Post date:** [March 19, 2019, 10:44pm UTC](https://discuss.elastic.co/t/refuse-field-type-change-in-mapping/173059/1 "2019-03-19T22:44:51Z")

</div>

Hi

Is it possible to ignore data not passing the mapping, like date type for @timestamp. It messes up my index pattern where 99% is all fine.

Most of my index mappings looks like these, which are fine:  
{  
"mapping": {  
"unitylog": {  
"properties": {  
"@timestamp": {  
"type": "date",  
"format": "yyyy-MM-dd HH:mm:ss.SSS"  
},  
"Component": {  
"type": "text"  
},  
"Details": {  
"type": "text"  
},  
"Level": {  
"type": "integer"  
},  
"OperationId": {  
"type": "text"  
},  
"SystemLogId": {  
"type": "integer"  
},  
"TenantId": {  
"type": "text"  
},  
"host": {  
"type": "text"  
},  
"message": {  
"type": "text"  
}  
}  
}  
}  
}

But a few indexes looks like these, I suspect it being some illegal data:  
{  
"mapping": {  
"unitylog": {  
"properties": {  
"@timestamp": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"Component": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"Details": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"Level": {  
"type": "long"  
},  
"OperationId": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"SystemLogId": {  
"type": "long"  
},  
"TenantId": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"message": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [March 20, 2019, 6:09am UTC](https://discuss.elastic.co/t/refuse-field-type-change-in-mapping/173059/2 "2019-03-20T06:09:43Z")

</div>

Hi,

You can use dynamic template and set that all fields named timestamp must be datetime if it fail it will return error. This way you are sure to have a correct mapping.

Check about the documentation for more details.  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html)

Hope it help.

---

<div class="post-metadata">

**Author:** ![mortenb123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mortenb123/32/37227_2.png) [@mortenb123](https://discuss.elastic.co/u/mortenb123)\
**Post date:** [March 27, 2019, 10:43am UTC](https://discuss.elastic.co/t/refuse-field-type-change-in-mapping/173059/3 "2019-03-27T10:43:58Z")

</div>

Thanks Dynamic Templating was the keyword, I manage to fix this by firstly specifying no field to be empty and improving the extraction sql.

---

<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:** [April 24, 2019, 10:44am UTC](https://discuss.elastic.co/t/refuse-field-type-change-in-mapping/173059/4 "2019-04-24T10:44:09Z")

</div>

Closed on April 24, 2019, 10:44am UTC

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