# How to force mapper\_parsing\_exception? from ElasticSearch to prevent accepting different types for a specific field

**URL:** <https://discuss.elastic.co/t/how-to-force-mapper-parsing-exception-from-elasticsearch-to-prevent-accepting-different-types-for-a-specific-field/315485>\
**Category:** Elasticsearch\
**Created:** [September 29, 2022, 5:05pm UTC](https://discuss.elastic.co/t/how-to-force-mapper-parsing-exception-from-elasticsearch-to-prevent-accepting-different-types-for-a-specific-field/315485 "2022-09-29T17:05:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saeedeh\_Moghimi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saeedeh_moghimi/32/111465_2.png) [@Saeedeh\_Moghimi](https://discuss.elastic.co/u/Saeedeh_Moghimi)\
**Post date:** [September 29, 2022, 5:05pm UTC](https://discuss.elastic.co/t/how-to-force-mapper-parsing-exception-from-elasticsearch-to-prevent-accepting-different-types-for-a-specific-field/315485/1 "2022-09-29T17:05:31Z")

</div>

I have a _production_ index with a `date` type field, which causes the error of  
`Field [tagSet.items.value] of type [text] does not support custom formats` in Kibana.  
I've created another index for test and whenever I want to POST a document with a text type instead a of `date` type, it prevents indexing the document and shows this error:  
`mapper_parsing_exception`

I'm wondering how this didn't happen on my _production_ index, if Elasticsearch had prevented indexing the document with wrong type values I wouldn't had any problems.

Is there any way to **PREVENT** Elasticsearch to accept documents with different types for a field?

---

<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 30, 2022, 3:38am UTC](https://discuss.elastic.co/t/how-to-force-mapper-parsing-exception-from-elasticsearch-to-prevent-accepting-different-types-for-a-specific-field/315485/2 "2022-09-30T03:38:52Z")

</div>

Elasticsearch allows you to define mappings in index templates.You can there specify that your field is a date and that will be enforced. If you try to insert a text value that can not be parsed as a date you will get a mapper error.

If you do not have an index template with mapping for the field in place, Elasticsearch will try to deduce the type based on the first document it encounters with this field. It will at that point depend on the data which type the field is mapped as. If it happens to be a date it could be set to date and if it is some other string it would be mapped as text. From that point on that field type will be validated. If the field was mapped as text it will accept any string and you will not see errors. If it was mapped as date you would see errors for non-compatible strings.

---

<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 28, 2022, 3:38am UTC](https://discuss.elastic.co/t/how-to-force-mapper-parsing-exception-from-elasticsearch-to-prevent-accepting-different-types-for-a-specific-field/315485/3 "2022-10-28T03:38:59Z")

</div>

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