# Indexing documents with different data types for a same field

**URL:** <https://discuss.elastic.co/t/indexing-documents-with-different-data-types-for-a-same-field/268086>\
**Category:** Elasticsearch\
**Created:** [March 23, 2021, 11:32am UTC](https://discuss.elastic.co/t/indexing-documents-with-different-data-types-for-a-same-field/268086 "2021-03-23T11:32:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashit\_pupu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashit_pupu/32/101113_2.png) [@ashit\_pupu](https://discuss.elastic.co/u/ashit_pupu)\
**Post date:** [March 23, 2021, 11:32am UTC](https://discuss.elastic.co/t/indexing-documents-with-different-data-types-for-a-same-field/268086/1 "2021-03-23T11:32:55Z")

</div>

I am using kafka connect elasticsearch sink to index data from kafka to elasticsearch index. The problem which I am facing is for particular event a field value is coming as text and for some event it's coming as object. The events for which it's coming as object, documents are being error-ed out. I tried using ignore malformed but it doesn't work for text field I tried though. Any other way by which we can at-least index those documents rather than loosing them.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 23, 2021, 11:31pm UTC](https://discuss.elastic.co/t/indexing-documents-with-different-data-types-for-a-same-field/268086/2 "2021-03-23T23:31:00Z")

</div>

Your best option is to solve it in kafka and force the type.

> [@ashit\_pupu](#):
>
> I tried using ignore malformed but it doesn't work for text field I tried though

What did you do? What didn't 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:** [April 20, 2021, 11:31pm UTC](https://discuss.elastic.co/t/indexing-documents-with-different-data-types-for-a-same-field/268086/3 "2021-04-20T23:31:53Z")

</div>

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