public static void createTemplateWithJson ( RestClient client , String template , String json , boolean force ) throws Exception { if ( isTemplateExist ( client , template ) ) { if ( force ) { logger . debug ( "Template [{}] already exists. Force is set. Removing it." , template ) ; removeTemplate ( client , template ) ; } else { logger . debug ( "Template [{}] already exists." , template ) ; } } if ( ! isTemplateExist ( client , template ) ) { logger . debug ( "Template [{}] doesn't exist. Creating it." , template ) ; createTemplateWithJsonInElasticsearch ( client , template , json ) ; } }
Create a new template in Elasticsearch