Error mapping with an object

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.

{
  "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

{
  "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

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.

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

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

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