Skip to content

Mapping should throw when field names with dots are specified #11337

@Mpdreamz

Description

@Mpdreamz

This was previously reported by @brwe on #5972 but closed in favour of this comment #6736 (comment) on #6736. That issue is now closed however so opening this again as a separate ticket so it won't be buried in the field name/path resolution refactor.

Consider the following mapping:

DELETE index123
PUT index123
{
  "mappings": {
    "people": {
      "properties": {
        "o.x.y": {
          "type": "string",
          "analyzer": "standard"
        },
        "o.x.z": {
          "type": "string",
          "boost": 2
        }
      }
    }
  }
}

POST index123/people
{
  "o" : {
    "x" : {
      "y" : "this is analyzed",
      "z" : "2015-05-25T22:13:04+02:00"
    }
  }
}

When we do a GET index123/_mapping we get the following mapping for people:

{
  "people": {
    "properties": {
      "o": {
        "properties": {
          "x": {
            "properties": {
              "y": {
                "type": "string"
              },
              "z": {
                "type": "date",
                "format": "dateOptionalTime"
              }
            }
          }
        }
      },
      "o.x.y": {
        "type": "string",
        "analyzer": "standard"
      },
      "o.x.z": {
        "type": "string",
        "boost": 2
      }
    }
  }
}

The string mapping for o.x.z is ignored and it becomes a date.

Interestingly if we had mapped it as an integer e.g

"o.x.z": {
    "type": "integer",
    "ignore_malformed": false
}

and indexed the following document

{
  "o" : {
    "x" : {
      "y" : "this is analyzed",
      "z" : "asdasda"
    }
  }
}

we DO get a NumberFormatException[For input string: \"asdasda\"]. Something is out of sync here.

Regardless of the field name/path resolution fixes it would be very handy if we'd get a mapping exception whenever we try to map a field with dots in it to prevent ambiguous mappings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions