Questions on migrating 8.2 for templates in Java

Hi, I'm migrating from elastic client 7.5.2 to 8.2. From HLRC to RestClient
I used to create Index template like this:

PutIndexTemplateRequest request = new PutIndexTemplateRequest(templateName);
        request.source(template, XContentType.JSON);
        AcknowledgedResponse putTemplateResponse = null;
        try {
            putTemplateResponse = restClient.indices().putTemplate(request, RequestOptions.DEFAULT);
            return putTemplateResponse.isAcknowledged();
        } catch (IOException e) {


  1. What is difference between PutTemplateRequest (java-client 8.2.0 API) and PutIndexTemplateRequest (java-client 8.2.0 API) ?
    I see both doing same.

  2. I'm using PutTemplateRequest (java-client 8.2.0 API)
    and my template creation fails. I'm using withJson to pass template json.

[es/indices.put_template] failed: [mapper_parsing_exception] Failed to parse mapping: dynamic template [remark] has invalid content [{"path_match":"*.*remark*","mapping":{"copy_to":["all"],"type":"object"}}], attempted to validate it with the following match_mapping_type: [object, string, long, double, boolean, date, binary]

2.a What's wrong with the request?
2.b I tried in Kibana dev tools with same JSON... PUT /_template/eua-cdb1_core_efk_8

It is success. How come ??

One Last Question :slight_smile:
It says #! Legacy index templates are deprecated in favor of composable templates.
Which latest Java method should we use ?

**NOTE: Some template creation got success with similar JSON structure.

Please help me with the information or examples

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