Pushing index templates fails on 7.9 with Java transport client

I am in the progress of migrating from 6.8 to 7.9. I have updated my index templates to work with the 7.9 format and if I submit the template via REST it installs fine; however, if I use the PutIndexTemplateRequest with the Java transport client it fails, complaining that it doesn't know what priority or meta is.

I know the Java transport client is now deprecated, but I'm trying to migrate one part at a time. I have created a cut-down template as an example to highlight the issue. The following template installs correctly when pushing over REST using Postman:

PUT localhost:9200/_index_template/simple-template-example

{
  "index_patterns": [
    "my-indexes*"
  ],
  "template": {
    "settings": {
      "index": {
        "number_of_shards": "1",
        "number_of_replicas": "1",
        "refresh_interval": "4s"
      }
    },
    "mappings": {
      "properties": {
        "@timestamp": {
          "type": "date",
          "format": "YYYY-MM-dd'T'HH:mm:ssZ",
          "index": true
        },
        "checksum": {
          "type": "keyword",
          "index": true,
          "norms": false
        },
        "clientId": {
          "type": "long",
          "index": true
        },
        "issue": {
          "type": "text",
          "index": true,
          "norms": false,
          "fields": {
            "keyword": {
              "type": "keyword"
            }
          }
        }
      }
    }
  },
  "priority": 200,
  "version": 1,
  "_meta": {
    "description": "Example index that works fine via REST but fails via Java client"
  }
}

If I push the same template with the transport client it rejects the priority tag and fails. I had no issue pushing templates in Java with 6.8, but with 7.9 it fails. I have also tried pushing it a few different ways:

client.admin().indices().putTemplate(
        new PutIndexTemplateRequest(filename).source(content.getBytes(), XContentType.JSON)
);

or

PutIndexTemplateRequest request = new PutIndexTemplateRequest(filename);
request.source(content, XContentType.JSON);
AcknowledgedResponse response = client.admin().indices().execute(PutIndexTemplateAction.INSTANCE, request).get();

Can anyone see what I am doing wrong?

Thanks.

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