# Multi-fields and dynamic mapping

**URL:** <https://discuss.elastic.co/t/multi-fields-and-dynamic-mapping/79171>\
**Category:** Elasticsearch\
**Created:** [March 19, 2017, 1:27pm UTC](https://discuss.elastic.co/t/multi-fields-and-dynamic-mapping/79171 "2017-03-19T13:27:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shira\_Bendor](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Shira\_Bendor](https://discuss.elastic.co/u/Shira_Bendor)\
**Post date:** [March 19, 2017, 1:27pm UTC](https://discuss.elastic.co/t/multi-fields-and-dynamic-mapping/79171/1 "2017-03-19T13:27:44Z")

</div>

Hi,  
I'm getting started with ES and wrote a small test that indexes a few example documents.  
Some of my documents have fields which have several types (e.g. long and text). Before I go ahead and change the documents themselves, I want to understand if I can index it as multi-fields (I don't have an explicit mapping so using the dynamic mapping).

My document for example looks like this:

```
{
  "event-name": "metadata-property-updated",
  "name": "name 1",
  "type": "file",
  "updated-attributes": {
    "other": [
      {
        "attribute-name": "name",
        "attribute-type": "string",
        "new-value": "new name",
        "old-value": "old name"
      },
      {
        "attribute-name": "count",
        "attribute-type": "integer",
        "old-value": 3,
        "new-value": 4
      }
    ]
  }
}

```

And I'm getting the error:

> java.lang.IllegalArgumentException: mapper [updated-attributes.other.new-value] of different type, current\_type [long], merged\_type [text]

---

<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:** [March 19, 2017, 2:06pm UTC](https://discuss.elastic.co/t/multi-fields-and-dynamic-mapping/79171/2 "2017-03-19T14:06:21Z")

</div>

You can't do that.

---

<div class="post-metadata">

**Author:** ![Shira\_Bendor](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Shira\_Bendor](https://discuss.elastic.co/u/Shira_Bendor)\
**Post date:** [March 19, 2017, 6:05pm UTC](https://discuss.elastic.co/t/multi-fields-and-dynamic-mapping/79171/3 "2017-03-19T18:05:11Z")

</div>

Thank you for the quick response!  
Can I do that if I define full static mapping of my index? Or I must change my documents?

---

<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:** [March 19, 2017, 6:29pm UTC](https://discuss.elastic.co/t/multi-fields-and-dynamic-mapping/79171/4 "2017-03-19T18:29:26Z")

</div>

You must change your documents.

Field `updated-attributes.other.new-value` can't be both a String and a Number.

---

<div class="post-metadata">

**Author:** ![Shira\_Bendor](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Shira\_Bendor](https://discuss.elastic.co/u/Shira_Bendor)\
**Post date:** [March 19, 2017, 6:47pm UTC](https://discuss.elastic.co/t/multi-fields-and-dynamic-mapping/79171/5 "2017-03-19T18:47:54Z")

</div>

Got it. Thanks.

---

<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 16, 2017, 6:48pm UTC](https://discuss.elastic.co/t/multi-fields-and-dynamic-mapping/79171/6 "2017-04-16T18:48:51Z")

</div>

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