# Varying schema problem

**URL:** <https://discuss.elastic.co/t/varying-schema-problem/109969>\
**Category:** Elasticsearch\
**Created:** [December 1, 2017, 5:41pm UTC](https://discuss.elastic.co/t/varying-schema-problem/109969 "2017-12-01T17:41:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johntadd](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@johntadd](https://discuss.elastic.co/u/johntadd)\
**Post date:** [December 1, 2017, 5:41pm UTC](https://discuss.elastic.co/t/varying-schema-problem/109969/1 "2017-12-01T17:41:33Z")

</div>

I have a tons of complicated xml files I want to transform to json, then pushing to elasticsearch. When pushing to elastichsearch it throws some exceptions such as number format

```
Caused by: java.lang.NumberFormatException: For input string: "664;3392"
...
org.elasticsearch.index.mapper.MapperParsingException: failed to parse [tag1.subtag1]

```

However because each xml file varies drastically. The first json, content converted from xml, get indexed would be very different from the rest of xml. So I would like to check if there's any way to update mapping dynamically?

I appreciate any suggestions.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 1, 2017, 6:01pm UTC](https://discuss.elastic.co/t/varying-schema-problem/109969/2 "2017-12-01T18:01:06Z")

</div>

You need to force the mapping before the first document gets indexed.

Use a `text` type for text fields.

---

<div class="post-metadata">

**Author:** ![johntadd](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@johntadd](https://discuss.elastic.co/u/johntadd)\
**Post date:** [December 4, 2017, 3:10pm UTC](https://discuss.elastic.co/t/varying-schema-problem/109969/3 "2017-12-04T15:10:46Z")

</div>

Updating by forcing mapping to string type solve my problem. Thanks for your help.

---

<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:** [January 1, 2018, 3:11pm UTC](https://discuss.elastic.co/t/varying-schema-problem/109969/4 "2018-01-01T15:11:01Z")

</div>

Closed on January 1, 2018, 3:11pm UTC

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