# \[JAVA\] Client CreateIndexRequest is failing with dynamic templates

**URL:** <https://discuss.elastic.co/t/java-client-createindexrequest-is-failing-with-dynamic-templates/359217>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [May 9, 2024, 9:21pm UTC](https://discuss.elastic.co/t/java-client-createindexrequest-is-failing-with-dynamic-templates/359217 "2024-05-09T21:21:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nkachami](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@nkachami](https://discuss.elastic.co/u/nkachami)\
**Post date:** [May 9, 2024, 9:21pm UTC](https://discuss.elastic.co/t/java-client-createindexrequest-is-failing-with-dynamic-templates/359217/1 "2024-05-09T21:21:58Z")

</div>

Using:

```auto
<dependency>
        <groupId>co.elastic.clients</groupId>
        <artifactId>elasticsearch-java</artifactId>
        <version>8.13.4</version>
</dependency>

```

When executing something like:

```auto
CreateIndexRequest createIndexRequest = CreateIndexRequest.of(b -> b
         .index(indexName)
         .withJson(input)
);
CreateIndexResponse response = elasticsearchAsyncClient.indices().create(createIndexRequest).get();

```

Where input contains an elasticsearch schema that utilizes dynamic templates with path\_match where its value is an array like:

```auto
{
  "settings": {
    // Some settings
  },
  "mappings": {
    "dynamic": "strict",
    "dynamic_templates": [
      {
        "some_template": {
          "path_match": [
            "some_field",
            "some_other_field"
          ],
          "mapping": {
          }
        }
      }
    ],
    "properties": {
      // Some properties
    }
  }
}

```

Is failing with error:

```auto
co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch._types.mapping.DynamicTemplate: co.elastic.clients.json.UnexpectedJsonEventException: Unexpected JSON event 'START_ARRAY' instead of '[KEY_NAME, VALUE_STRING, VALUE_NUMBER, VALUE_TRUE, VALUE_FALSE]'

```

---

<div class="post-metadata">

**Author:** ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)\
**Post date:** [May 10, 2024, 8:24am UTC](https://discuss.elastic.co/t/java-client-createindexrequest-is-failing-with-dynamic-templates/359217/2 "2024-05-10T08:24:23Z")

</div>

Hello!  
This is a know issue, the client still needs to allow arrays instead of just strings for Dynamic Templates. You can follow our progress on this issue [here](https://github.com/elastic/elasticsearch-java/issues/648).
