Skip to content

Dynamic Template accepts invalid mapping values #24419

@dmarkhas

Description

@dmarkhas

Elasticsearch version: 5.3.0

Plugins installed: []

JVM version: 1.8.0.92

OS version: SLES11SP4

Description of the problem including expected versus actual behavior:

When creating a dynamic template, a user can provide an invalid value to the "index" parameter (true/false instead of "analzyed","not_analyzed"). ElasticSearch accepts the template and does not warn about the invalid value, but any documents that will match this template will be discarded.

ElasticSearch should validate the template and reject it if it's malformed.

Steps to reproduce:

  1. Create a dynamic template as follows
    {
    "string_fields": {
    "mapping": {
    "index": true,
    "type": "text",
    "fields": {
    "raw": {
    "ignore_above": 10000,
    "index": "not_analyzed",
    "type": "keyword"
    }
    }
    },
    "match_mapping_type": "string",
    "match": "*"
    }
    }
  2. Index any document with a string field
  3. The following exception will appear in the log:

java.lang.IllegalArgumentException: Can't parse [index] value [true] for field [YOUR_FIELD_NAME_HERE], expected [no], [not_analyzed] or [analyzed]
at org.elasticsearch.index.mapper.StringFieldMapper$TypeParser.parse(StringFieldMapper.java:210) ~[elasticsearch-5.3.0.jar:5.3.0]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions