Dynamic templates don´t seem to support object types

Our team is currently using ElasticSearch 6.2.2. We were trying create events with object datatype using the character '.'. It seems that dynamic templates don´t support this. When we add a event with the object datatype it throws an error.

ElasticSearch 6.6.1

We created the dynamic template that transforms all fields to keyword datatype.

$ curl -XPOST localhost:9200/_template/test_index1?pretty -d '{"index_patterns": ["test_index*"], "settings": {"number_of_shards": 1, "number_of_replicas": 1, "index.merge.scheduler.max_thread_count" : 1, "index.codec": "best_compression", "analysis": {"char_filter": {"quote": {"type": "mapping", "mappings": ["« => \"", "» => \""] } }, "normalizer": {"lowercase_folding_normalizer": {"type": "custom", "char_filter": ["quote"], "filter": ["lowercase", "asciifolding"] } } } }, "mappings" : {"_doc" : {"dynamic_templates": [{"all_strings": {"match": "*", "mapping": {"type": "keyword"} } } ] } } }' -H "Content-Type: application/json"
{
  "acknowledged" : true
}

By adding an object datatype it throws the following error:

$ curl -XPUT localhost:9200/test_index1/_doc/1?pretty -d '{"first.second": "value"}' -H "Content-Type: application/json"
{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse",
    "caused_by" : {
      "type" : "class_cast_exception",
      "reason" : "class org.elasticsearch.index.mapper.KeywordFieldMapper cannot be cast to class org.elasticsearch.index.mapper.ObjectMapper (org.elasticsearch.index.mapper.KeywordFieldMapper and org.elasticsearch.index.mapper.ObjectMapper are in unnamed module of loader 'app')"
    }
  },
  "status" : 400
}

We tested the same in ElasticSearch 6.2.2 :

 $ curl -XPOST localhost:9200/_template/test_index1?pretty -d '{"index_patterns": ["test_index*"], "settings": {"number_of_shards": 1, "number_of_replicas": 1, "index.merge.scheduler.max_thread_count" : 1, "index.codec": "best_compression", "analysis": {"char_filter": {"quote": {"type": "mapping", "mappings": ["« => \"", "» => \""] } }, "normalizer": {"lowercase_folding_normalizer": {"type": "custom", "char_filter": ["quote"], "filter": ["lowercase", "asciifolding"] } } } }, "mappings" : {"_doc" : {"dynamic_templates": [{"all_strings": {"match": "*", "mapping": {"type": "keyword"} } } ] } } }' -H "Content-Type: application/json"
{
  "acknowledged" : true
}

$ curl -XPUT localhost:9200/test_index1/_doc/1?pretty -d '{"first.second": "value"}' -H "Content-Type: application/json"
{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse",
    "caused_by" : {
      "type" : "class_cast_exception",
      "reason" : "org.elasticsearch.index.mapper.KeywordFieldMapper cannot be cast to org.elasticsearch.index.mapper.ObjectMapper"
    }
  },
  "status" : 400
}

Is this an bug in the dynamic templates feature?

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