Java prepareGetTemplates Exists call?


(Bill) #1

Is there a simple way to see if template exists in Java?

client.admin().indices().prepareGetTemplates(TEMPLATE_NAME).get()

Was thinking more of a prepareExistsTemplates() to do something like HEAD call


(David Pilato) #2

This is how I implemented it so far:

public static boolean isTemplateExist(Client client, String template) {
    return !client.admin().indices().prepareGetTemplates(template).get().getIndexTemplates().isEmpty();
}

(system) #3

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