Rest High Level Client Bulk Api write request failing: mapper_parsing_exception

Hi
We recently migrated to ES 6.1.2 from ES 1.7.
in the older version we had index mapping as

 [
  {
    "ts_dynamic_template": {
      "mapping": {
        "norms": {
          "enabled": false
        },
        "index": "not_analyzed",
        "type": "string"
      },
      "match_mapping_type": "string"
    }
  }
]

that used to run flawless. With ES 6 we moved to this mapping with type keyword, since we did not want the properties/fields analysed

"dynamic_templates": [
      {
        "ts_dynamic_template": {
          "match_mapping_type": "string",
          "mapping": {
            "index": true,
            "norms": false,
            "type": "keyword"
          }
        }
      }
    ]

However, our high level rest client keeps throwing this error for a few fields which can have multiple types

    "Bulk [51a1df8358678f340d301811beef97f0] executed with failures ElasticsearchException[Elasticsearch exception [type=mapper_parsing_exception, reason=object mapping for [eventType] tried to parse field [eventType] as object, but found a concrete value]]"
org.elasticsearch.ElasticsearchException: Elasticsearch exception [type=mapper_parsing_exception, reason=object mapping for [eventType] tried to parse field [eventType] as object, but found a concrete value]
        at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:490)
        at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:406)
        at org.elasticsearch.action.bulk.BulkItemResponse.fromXContent(BulkItemResponse.java:135)
        at org.elasticsearch.action.bulk.BulkResponse.fromXContent(BulkResponse.java:198)

Pretty much stuck at this. Any ideas?

Once a data type has been fixed in the mapping, it cannot be changed.

In your example, I assume that the first occurrence of the field in question looked like

{
  "eventType": {
    "internal_1": "value"
  }
}

whereas the document that led to the error provided an actual string or numerical value instead of the internal object.

You'll have to ensure that your objects all confirm to the mapped structure. Dynamic templates only ensure that the desired mapping is generated the first time a field is encountered. They do not allow for different data types to be used. Please check the actual mapping generated for your field.

@Magnus_Kessler So the problem here is with dots.

When we try to write "foo.bar.baz": "value", it gets mapped as

"foo": {
        "properties": {
          "bar": {
            "properties": {
              "baz": {
                "type": "keyword"
              }
            }
          }
        }
      }

Any way to get it as foo.bar.baz ?

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