@Override public void execute(IndexTemplate indexTemplate) { try { createClient().admin().indices().putTemplate( new PutIndexTemplateRequest() .name(indexTemplate.getName()) .source(indexTemplate.getSource(), XContentType.JSON) ); } catch (Exception e) { throw new ConfigurationException(e.getMessage(), e); } }
@Override public void execute(IndexTemplate indexTemplate) { try { createClient().admin().indices().putTemplate( new PutIndexTemplateRequest() .name(indexTemplate.getName()) .source(indexTemplate.getSource(), XContentType.JSON) ); } catch (Exception e) { throw new ConfigurationException(e.getMessage(), e); } }
@Override public void execute(IndexTemplate indexTemplate) { try { createClient().admin().indices().putTemplate( new PutIndexTemplateRequest() .name(indexTemplate.getName()) .source(indexTemplate.getSource()) ); } catch (Exception e) { throw new ConfigurationException(e); } }
@Override public void execute(IndexTemplate indexTemplate) { TemplateAction templateAction = new PutTemplate.Builder(indexTemplate.getName(), indexTemplate.getSource()).build(); try { JestResult result = createClient().execute(templateAction); if (!result.isSucceeded()) { throw new ConfigurationException("IndexTemplate not added: " + result.getErrorMessage()); } } catch (IOException e) { throw new ConfigurationException("IndexTemplate not added: " + e.getMessage()); } }
@Test public void startsWhenSetupCorrectlyWithNameAndPath() { // given IndexTemplate.Builder builder = createTestIndexTemplateBuilder(); builder.withName(TEST_INDEX_TEMPLATE) .withPath(TEST_PATH); // when IndexTemplate indexTemplate = builder.build(); // then Assert.assertNotNull(indexTemplate); Assert.assertNotNull(indexTemplate.getName()); Assert.assertNotNull(indexTemplate.getSource()); }
@Test public void startsWhenSetupCorrectlyWithNameAndSource() { // given IndexTemplate.Builder builder = createTestIndexTemplateBuilder(); builder.withName(TEST_INDEX_TEMPLATE) .withPath(null) .withSource(TEST_SOURCE); // when IndexTemplate indexTemplate = builder.build(); // then Assert.assertNotNull(indexTemplate); Assert.assertNotNull(indexTemplate.getName()); Assert.assertNotNull(indexTemplate.getSource()); }