# Index fails for first document in the index despite ignore\_malformed being set

**URL:** <https://discuss.elastic.co/t/index-fails-for-first-document-in-the-index-despite-ignore-malformed-being-set/151262>\
**Category:** Elasticsearch\
**Created:** [October 5, 2018, 5:33pm UTC](https://discuss.elastic.co/t/index-fails-for-first-document-in-the-index-despite-ignore-malformed-being-set/151262 "2018-10-05T17:33:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arcadia](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@arcadia](https://discuss.elastic.co/u/arcadia)\
**Post date:** [October 5, 2018, 5:33pm UTC](https://discuss.elastic.co/t/index-fails-for-first-document-in-the-index-despite-ignore-malformed-being-set/151262/1 "2018-10-05T17:33:03Z")

</div>

If the first record being indexed has a date field in the record, and the first occurrence of that field is a valid date, such that Elasticsearch maps the type of the field to date, then later in the same record there is an occurrence of that same field but with an invalid date, index fails with the following reason:

mapper date.field.path of different type, current\_type date, merged\_type text

This error doesn't happen if the first record indexed has no invalid date, but a subsequent record with an invalid date is indexed. In that case, the ignore\_malformed setting works, and Elasticsearch correctly omits that field.

But it doesn't work if the invalid field is in the first document being indexed. This seems to be a bug.

As far as I can tell, the only way to avoid this kind of error is create an index mapping setting that field's type to text before indexing. That's a reasonable solution, but I still feel like ignore\_malformed should capture this case.

---

<div class="post-metadata">

**Author:** ![andrx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrx/32/35028_2.png) [@andrx](https://discuss.elastic.co/u/andrx)\
**Post date:** [October 6, 2018, 2:49am UTC](https://discuss.elastic.co/t/index-fails-for-first-document-in-the-index-despite-ignore-malformed-being-set/151262/2 "2018-10-06T02:49:33Z")

</div>

You're right, it probably guessed the wrong type for the field when schema was automatically created for you. so, your solution of manually defining schema should work

---

<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, 2018, 2:49am UTC](https://discuss.elastic.co/t/index-fails-for-first-document-in-the-index-despite-ignore-malformed-being-set/151262/3 "2018-11-03T02:49:37Z")

</div>

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