# Array with mixed values

**URL:** <https://discuss.elastic.co/t/array-with-mixed-values/38592>\
**Category:** Elasticsearch\
**Created:** [January 7, 2016, 10:23am UTC](https://discuss.elastic.co/t/array-with-mixed-values/38592 "2016-01-07T10:23:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)\
**Post date:** [January 7, 2016, 10:23am UTC](https://discuss.elastic.co/t/array-with-mixed-values/38592/1 "2016-01-07T10:23:22Z")

</div>

I have some "funny" data which looks like this:

```
{"subsystem":["windows gui",{"major":5,"minor":1}]}

```

This is a valid JSON string, but it won't go into Elasticsearch.

If I define a dynamic template like

```
 {"subsystem": {"match":"subsystem","mapping": {"type": "string"}}}

```

and

```
{"index.mapping.ignore_malformed": "true"}

```

I get an Exception:

```
MapperParsingException[failed to parse [a.b.c.subsystem]]; nested: IllegalArgumentException[unknown property [major]];

```

So all I can do is to eliminate this part of my JSON before sending it to Elasticsearch.  
However, it would be helpful if Elasticsearch provided a way to handle this type of JSON structure dynamically.

---

<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:** [January 7, 2016, 10:58am UTC](https://discuss.elastic.co/t/array-with-mixed-values/38592/2 "2016-01-07T10:58:52Z")

</div>

If you don't want to index what is under `subsystem`, you can use [enabled](https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html).

---

<div class="post-metadata">

**Author:** ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)\
**Post date:** [January 7, 2016, 11:26am UTC](https://discuss.elastic.co/t/array-with-mixed-values/38592/3 "2016-01-07T11:26:54Z")

</div>

I have tried out your advice by adding this to dynamic\_templates:

```
{"subsystem": {"match":"subsystem","mapping": {"enabled": "false"}}}

```

but this seems to be ignored:

```
MapperParsingException[Merging dynamic updates triggered a conflict: mapper [a.bc.subsystem] of different type, current_type [string], merged_type [ObjectMapper]]

```

Maybe it does not work with dynamic\_templates?

---

<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:** [January 7, 2016, 12:43pm UTC](https://discuss.elastic.co/t/array-with-mixed-values/38592/4 "2016-01-07T12:43:25Z")

</div>

Yes because when dynamic mapping is applied it's already too late.

Don't do that in dynamic mapping. Why do you think you should do that there BTW?

---

<div class="post-metadata">

**Author:** ![Benjamin\_Gathmann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_gathmann/32/7561_2.png) [@Benjamin\_Gathmann](https://discuss.elastic.co/u/Benjamin_Gathmann)\
**Post date:** [January 7, 2016, 12:51pm UTC](https://discuss.elastic.co/t/array-with-mixed-values/38592/5 "2016-01-07T12:51:30Z")

</div>

This is because I am using dynamic mapping - my JSONs are deeply nested and some branches vary a lot, so I don't want to go through creating the complete index structure myself.  
In any case, I now simply pre-process the JSON before sending it to Elasticsearch, this seems to be the most efficient solution.

---

<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:** [July 5, 2017, 11:26pm UTC](https://discuss.elastic.co/t/array-with-mixed-values/38592/6 "2017-07-05T23:26:25Z")

</div>


