Setting dynamic_templates mapping field from Java using RestHighLevelClient 7.17 for ES v8.2

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
CreateIndexRequest indexRequest = new CreateIndexRequest();
indexRequest.index(indexName);
indexRequest.source(definition, XContentType.JSON);  // definition is a json string
{
  "mappings": {
    "dynamic_templates": [
      {
        "strings": {
          "match_mapping_type": "string",
          "mapping": {
            "type": "keyword"
          }
        }
      }
    ],
    "_routing": {
      "required": false
    },
    "properties": {
      // Properties here
    }
  },
  "settings": {
    "index.max_result_window": 500000
  }
}

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