sohil sohil - 1 year ago 97
Java Question

create an index template using the java api in elastic search

The current java API for elastic search documentation does not say anything about creating an index template.
I know I can create an index template using crud, but my elastic search index is going grow depending on the data I get. The data I have right now, it may be possible that the data may change. So instead of manually making an index and a template, I want to know if it can be done through writing a code in Java.


You can use the IndicesAdminClient to create a template

node.client().admin().indices().putTemplate(new PutIndexTemplateRequest("templatename").source(templateString));

PutIndexTemplateRequest has other methods to programatically build the template if you'd prefer to build it as a Java map, etc.