# Setting dynamic\_templates mapping field from Java using RestHighLevelClient 7.17 for ES v8.2

**URL:** <https://discuss.elastic.co/t/setting-dynamic-templates-mapping-field-from-java-using-resthighlevelclient-7-17-for-es-v8-2/309715>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [July 15, 2022, 7:55am UTC](https://discuss.elastic.co/t/setting-dynamic-templates-mapping-field-from-java-using-resthighlevelclient-7-17-for-es-v8-2/309715 "2022-07-15T07:55:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CamiloPDL](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/camilopdl/32/108339_2.png) [@CamiloPDL](https://discuss.elastic.co/u/CamiloPDL)\
**Post date:** [July 15, 2022, 7:55am UTC](https://discuss.elastic.co/t/setting-dynamic-templates-mapping-field-from-java-using-resthighlevelclient-7-17-for-es-v8-2/309715/1 "2022-07-15T07:55:29Z")

</div>

Hello community!  
I am trying to use RestHighLevelClient (RHLC) 7.17 with compatibility mode to create indices on an ES cluster running version 8.2. I know RHLC is deprecated but at this moment we cannot afford to migrate everything to the new java client library.  
The common queries for indexing a document, searching are working well using compatibility mode. The issue I have is when creating an index from a json definition. The array of objects for dynamic\_templates is never parsed by the library. If I remove the dynamic\_templates it works well, but I have not found how to set this later because making a request to update the mapping does not work neither. So my questions are

1. Is there a way to make the json definition below to work with RHLC 7.17 to create an index in ES v8.2?
2. Is there a way to set the dynamic\_templates using RHLC v7.17 to set this mapping in an index in ES v8?  
Thanks

```auto
CreateIndexRequest indexRequest = new CreateIndexRequest();
indexRequest.index(indexName);
indexRequest.source(definition, XContentType.JSON); // definition is a json string

```

```auto
{
  "mappings": {
    "dynamic_templates": [
      {
        "strings": {
          "match_mapping_type": "string",
          "mapping": {
            "type": "keyword"
          }
        }
      }
    ],
    "_routing": {
      "required": false
    },
    "properties": {
      // Properties here
    }
  },
  "settings": {
    "index.max_result_window": 500000
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 12, 2022, 7:56am UTC](https://discuss.elastic.co/t/setting-dynamic-templates-mapping-field-from-java-using-resthighlevelclient-7-17-for-es-v8-2/309715/2 "2022-08-12T07:56:28Z")

</div>

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