@Override public GetIndexTemplatesRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new GetIndexTemplatesRequestBuilder(client, this); } }
/** * Initializes the index with required templates and mappings. */ private void initIndex() throws Exception { // 0. Add the tasklog template GetIndexTemplatesResponse result = elasticSearchClient.admin() .indices() .prepareGetTemplates("tasklog_template") .execute() .actionGet(); if (result.getIndexTemplates().isEmpty()) { logger.info("Creating the index template 'tasklog_template'"); InputStream stream = ElasticSearchDAOV5.class .getResourceAsStream("/template_tasklog.json"); byte[] templateSource = IOUtils.toByteArray(stream); try { elasticSearchClient.admin() .indices() .preparePutTemplate("tasklog_template") .setSource(templateSource, XContentType.JSON) .execute() .actionGet(); } catch (Exception e) { logger.error("Failed to init tasklog_template", e); } } }
/** * Check if a template exists * @param client Elasticsearch client * @param template template name * @return true if the template exists * @deprecated Will be removed when we don't support TransportClient anymore */ @Deprecated public static boolean isTemplateExist(Client client, String template) { return !client.admin().indices().prepareGetTemplates(template).get().getIndexTemplates().isEmpty(); }
/** * Check if a template exists * @param client Elasticsearch client * @param template template name * @return true if the template exists * @deprecated Will be removed when we don't support TransportClient anymore */ @Deprecated public static boolean isTemplateExist(Client client, String template) { return !client.admin().indices().prepareGetTemplates(template).get().getIndexTemplates().isEmpty(); }
@Override public GetIndexTemplatesRequestBuilder prepareGetTemplates(String... names) { return new GetIndexTemplatesRequestBuilder(this, GetIndexTemplatesAction.INSTANCE, names); }
/** * Removes all templates, except the templates defined in the exclude */ public void wipeAllTemplates(Set<String> exclude) { if (size() > 0) { GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates().get(); for (IndexTemplateMetaData indexTemplate : response.getIndexTemplates()) { if (exclude.contains(indexTemplate.getName())) { continue; } try { client().admin().indices().prepareDeleteTemplate(indexTemplate.getName()).execute().actionGet(); } catch (IndexTemplateMissingException e) { // ignore } } } }
@Override public GetIndexTemplatesRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new GetIndexTemplatesRequestBuilder(client, this); } }
@Override public GetIndexTemplatesRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new GetIndexTemplatesRequestBuilder(client, this); } }
@Override public GetIndexTemplatesRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new GetIndexTemplatesRequestBuilder(client, this); } }
@Override public GetIndexTemplatesRequestBuilder prepareGetTemplates(String... names) { return new GetIndexTemplatesRequestBuilder(this, GetIndexTemplatesAction.INSTANCE, names); }
@Override public GetIndexTemplatesRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new GetIndexTemplatesRequestBuilder(client, this); } }
@Override public GetIndexTemplatesRequestBuilder prepareGetTemplates(String... names) { return new GetIndexTemplatesRequestBuilder(this, GetIndexTemplatesAction.INSTANCE, names); }
@Override public GetIndexTemplatesRequestBuilder prepareGetTemplates(String... names) { return new GetIndexTemplatesRequestBuilder(this, GetIndexTemplatesAction.INSTANCE, names); }