Skip to content

Source includes triggers MapperParsingException/IllegalStateException if field is in an array #92480

Closed
@TheRiffRafi

Description

@TheRiffRafi

Elasticsearch Version

8.5.3

Installed Plugins

No response

Java Version

bundled

OS Version

n/a

Problem Description

In version 7.x of ES you can set an "includes" settings in the "_source" mapping definition for a field within a nested field.
If you are indexing a document that contains multiple nested fields where one of the fields does not contain a particular field, the document indexes without problems.

However, doing the same in version 8.5.3 fails with a "reason": "Unclosed object or array found".

Steps to Reproduce

Create a mapping like this:

PUT testnested
{
  "mappings": {
    "_source": {
      "includes": [
        "doc.field2","doc.field1.field3"
      ]
    },
    "properties": {
      "doc": {
        "properties": {
          "field1": {
            "type": "nested",
            "properties": {
              "field1n1": {
                "type": "nested",
                "properties": {
                  "name": {
                    "type": "text"
                  }
                }
              },
              "field3": {
                "type": "text"
              }
            }
          },
          "field2": {
            "type": "object"
          }
            
          }
        }
      }
    }
  }

Then index a document like this:

POST testnested/_doc
{
  "doc": {
    "field1": [
      {
        "field1n1": [
          {
            "name": "peter"
          },
          {
            "name": "parker"
          }
        ],
        "field3": "test"
      },
      {
        
        "field4": "testfield3"
      }
    ]
  }
}

Receive error:

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse",
    "caused_by": {
      "type": "illegal_state_exception",
      "reason": "Failed to close the XContentBuilder",
      "caused_by": {
        "type": "i_o_exception",
        "reason": "Unclosed object or array found"
      }
    }
  },
  "status": 400
}

Logs (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions