Skip to content

Recursive path_match in dynamic template does not work for trailing * #32595

@kylelyk

Description

@kylelyk

Elasticsearch version: 6.2.4

Plugins installed: []

JVM version: 1.8.0_172

OS version: MacOS (Darwin Kernel Version 15.6.0)

Description of the problem including expected versus actual behavior:

PUT test
{
  "mappings": {
    "_doc": {
      "dynamic_templates": [
        {
          "template": {
            "path_match": "prop1.prop2.*",
            "mapping": {
              "type": "keyword",
              "index": false
            }
          }
        }
      ],
      "properties": {
        "prop1": {
          "properties": {
            "prop2": {
              "type": "object",
              "dynamic": true
            }
          }
        }
      }
    }
  }
}
PUT test/_doc/1
{
  "prop1": {
    "prop2": {
      "prop3": {
        "prop4": {
          "field": "bar"
        }
      }
    }
  }
}

Returns the following error:

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse [prop1.prop2.prop3]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse [prop1.prop2.prop3]",
    "caused_by": {
      "type": "illegal_state_exception",
      "reason": "Can't get text on a START_OBJECT at 4:16"
    }
  },
  "status": 400
}

However, if you replace the path_match in the dynamic template to prop1.prop2.*.field, it works as expected and matches prop1.prop2.prop3.prop4.field.

Metadata

Metadata

Assignees

Labels

:Search Foundations/MappingIndex mappings, including merging and defining field types>docsGeneral docs changesTeam:Search FoundationsMeta label for the Search Foundations team in Elasticsearch

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions