Mapping util.Map instances to Object fails

I discovered that Dynamic Templates are the way to go. As described in this Stackoverflow answer a Dynamic Template needs to be created that instructs Elasticsearch to index every sub-field of a given field in a specific way. In that sense, you are instructing Elasticsearch on how to create dynamic mappings.

Here is the Query that I use to create the template that I will use for my application:

PUT /archive_document
{
  "mappings": {
    "document": {
      "dynamic_templates": [
        {
          "map_string": {
            "match_mapping_type": "string",
            "path_match": "fields.*",
            "mapping": {
              "type": "text"
            }
          }
        }
      ]
    }
  }
}

This of course needs further adjustments to really be usable.