# Error mapping with an object

**URL:** <https://discuss.elastic.co/t/error-mapping-with-an-object/262390>\
**Category:** Elasticsearch\
**Created:** [January 27, 2021, 3:43pm UTC](https://discuss.elastic.co/t/error-mapping-with-an-object/262390 "2021-01-27T15:43:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Katherinne\_Quintero](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/katherinne_quintero/32/42348_2.png) [@Katherinne\_Quintero](https://discuss.elastic.co/u/Katherinne_Quintero)\
**Post date:** [January 27, 2021, 3:43pm UTC](https://discuss.elastic.co/t/error-mapping-with-an-object/262390/1 "2021-01-27T15:43:51Z")

</div>

Hello, I am trying to save a document with the following structure but it gives me an error, I understand that it is an error in the map since validationForm.content.value is for some cases as an object and in other cases not.

How can I generate the map, because I tried don nested but it generates the same error, we need to save this structure from this document.

```auto
{
  "productId": "600f4dd59a40ae00080712df",
  "clientId": "600f4dd59a40ae00080712db",
  "addressId": "600f4dd59a40ae00080712dd",
  "validationForm": {
    "content": [
      {
        "id": "600840d9fdcedc00081cc744",
        "value": "17.388.047-2",
        "key": "rut",
        "label": "RUT",
        "type": "rut"
      },
      {
        "id": "600840d9fdcedc00081cc745",
        "value": "Esteban Alfredo ",
        "key": "name",
        "label": "Nombre",
        "type": "text"
      },
      {
        "id": "600840d9fdcedc00081cc747",
        "value": {
          "lat": -32.7293178,
          "lng": -71.2074179,
          "placeId": "ChIJgagy_rjKiZYR7aR3Ms_SiX4",
          "address": "Pasaje 6 315, Nogales, Chile",
          "additionalInfo": "pasaje 6 315, NOGALES ",
          "street": "Pasaje 6",
          "streetNumber": "315",
          "commune": "Nogales",
          "region": "Valparaíso",
          "formattedAddress": null
        },
        "key": "address",
        "label": "Dirección",
        "type": "address"
      }
    ]
  }
}

```

Error

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "can't merge a non object mapping [validationForm.content.value] with an object mapping"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "can't merge a non object mapping [validationForm.content.value] with an object mapping"
  },
  "status" : 400
}

```

thanks

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 27, 2021, 4:40pm UTC](https://discuss.elastic.co/t/error-mapping-with-an-object/262390/2 "2021-01-27T16:40:22Z")

</div>

In Elasticsearch a field can only have one mapping so you will need to change the structure of the document or possibly not index parts of it.

---

<div class="post-metadata">

**Author:** ![Katherinne\_Quintero](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/katherinne_quintero/32/42348_2.png) [@Katherinne\_Quintero](https://discuss.elastic.co/u/Katherinne_Quintero)\
**Post date:** [January 28, 2021, 10:00pm UTC](https://discuss.elastic.co/t/error-mapping-with-an-object/262390/3 "2021-01-28T22:00:41Z")

</div>

Hello,

We found that it can be saved as an object type and indicate enabled in the map, although I understand that we cannot search through this field, it allows us to save the structure.

the example of the map stayed like this

```auto
{
  "mappings": {
    "properties": {
      "productId": {
        "type": "keyword"
      },
      "clientId": {
        "type": "keyword"
      },
      "addressId": {
        "type": "keyword"
      },
      "validationForm": { 
        "type": "object",
        "enabled": false
      }
    }
  }
}

```

---

<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:** [February 25, 2021, 10:01pm UTC](https://discuss.elastic.co/t/error-mapping-with-an-object/262390/4 "2021-02-25T22:01:10Z")

</div>

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