title: Elasticsearch: Failed to parse mapping [_doc]
body: <p>I'm trying to create a dynamic template mapping for the index and is continuously receiving the following error: </p>
  
  <p><code>Invocation of init method failed; nested exception is ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [mappings : {dynamic_templates=[{articleNumber={mapping={type=text, fields={keyword={type=keyword}}}, match_mapping_type=*, match=articleNumber*}}]}]]]; nested: ElasticsearchException[Elasticsearch exception [type=mapper_parsing_exception, reason=Root mapping definition has unsupported parameters:  [mappings : {dynamic_templates=[{articleNumber={mapping={type=text, fields={keyword={type=keyword}}}, match_mapping_type=*, match=articleNumber*}}]}]]];</code></p>
  
  <p>Here is the structure that I'm trying to create a mapping with: </p>
  
  <pre><code>{
    "mappings": {
      "dynamic_templates": [
        {
          "articleNumber": {
            "match_mapping_type": "*",
            "match": "articleNumber*",
            "mapping": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword"
                }
              }
            }
          }
        }
      ]
    }
  }
  </code></pre>
  
  <p>It is a mistake in the mapping structure? or everything is ok here and I should take a look at the way of parsing the mapping object?</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>this is the code that I'm using to create a mapping: </p>
  
  <pre><code>CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
  CreateIndexResponse createIndexResponse = getClient().indices().create(createIndexRequest.mapping(getIndexMapping()), RequestOptions.DEFAULT);
  
  private XContentBuilder getIndexMapping() throws IOException {
      String mappingObj = "{\"mappings\":{\"dynamic_templates\":[{\"articleNumber\":{\"match_mapping_type\":\"string\",\"match\":\"articleNumber*\",\"mapping\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\"}}}}}]}}";
      XContentBuilder b = XContentFactory.jsonBuilder().prettyPrint();
      try (XContentParser p = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, 
              null, mappingObj)) {
          b.copyCurrentStructure(p);
      }
      System.err.println(b.toString());
  
      return b;
  }
  </code></pre>