PutIndexTemplateRequest

Is there a replacement for the create method below in the new Java API? Thanks.

        	PutIndexTemplateRequest request = new PutIndexTemplateRequest(TEMPLATE_NAME);
        	request.create(false); // Required to allow update and not error out if template exists
        	request.source(Files.readAllBytes(file.toPath()), XContentType.JSON);
        	request.patterns(patterns);

Hi,
Sure, have a look at co.elastic.clients.elasticsearch.indices.PutIndexTemplateRequest (PutIndexTemplateRequest (java-client 8.10.2 API))
You will have something like:

PutIndexTemplateRequest templateRequest = new PutIndexTemplateRequest.Builder()
    .name(TEMPLATE_NAME)
    .indexPatterns(patterns)
    .withJson(yourJsonIS)
    .priority(50)
    .create(true) // don't allow overwrite
    .build();
PutIndexTemplateResponse putTemplateResponse = client.indices().putIndexTemplate(templateRequest)

Thanks. I'm still using version 7 and it doesn't exist there so it explains my confusion.

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