org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequestBuilder Java Examples
The following examples show how to use
org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequestBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultElasticSearchAdminService.java From vertx-elasticsearch-service with Apache License 2.0 | 6 votes |
@Override public void putTemplate(String name, JsonObject source, TemplateOptions options, Handler<AsyncResult<Void>> resultHandler) { final PutIndexTemplateRequestBuilder builder = new PutIndexTemplateRequestBuilder(service.getClient(), PutIndexTemplateAction.INSTANCE, name) .setSource(source.encode().getBytes(Charsets.UTF_8), XContentType.JSON); builder.execute(new ActionListener<PutIndexTemplateResponse>() { @Override public void onResponse(PutIndexTemplateResponse putIndexTemplateResponse) { resultHandler.handle(Future.succeededFuture()); } @Override public void onFailure(Exception e) { resultHandler.handle(Future.failedFuture(e)); } }); }
Example #2
Source File: AbstractESTest.java From elasticsearch-migration with Apache License 2.0 | 5 votes |
@SneakyThrows protected void createTemplate(final String template, final String definition) { final PutIndexTemplateRequestBuilder putIndexTemplateRequestBuilder = new PutIndexTemplateRequestBuilder(client, PutIndexTemplateAction.INSTANCE, template) .setSource(esObjectMapper.readValue(definition, Map.class)); assertThat(putIndexTemplateRequestBuilder.get().isAcknowledged(), is(true)); }
Example #3
Source File: ElasticsearchParentChildWriterIT.java From streams with Apache License 2.0 | 5 votes |
@BeforeClass public void prepareTestParentChildPersistWriter() throws Exception { testConfiguration = new ComponentConfigurator<>(ElasticsearchWriterConfiguration.class).detectConfiguration("ElasticsearchParentChildWriterIT"); testClient = ElasticsearchClientManager.getInstance(testConfiguration).client(); ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest(); ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet(); assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED); IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getIndex()); IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet(); if (indicesExistsResponse.isExists()) { DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(testConfiguration.getIndex()); DeleteIndexResponse deleteIndexResponse = testClient.admin().indices().delete(deleteIndexRequest).actionGet(); assertTrue(deleteIndexResponse.isAcknowledged()); } PutIndexTemplateRequestBuilder putTemplateRequestBuilder = testClient.admin().indices().preparePutTemplate("mappings"); URL templateURL = ElasticsearchParentChildWriterIT.class.getResource("/ActivityChildObjectParent.json"); ObjectNode template = MAPPER.readValue(templateURL, ObjectNode.class); String templateSource = MAPPER.writeValueAsString(template); putTemplateRequestBuilder.setSource(templateSource); testClient.admin().indices().putTemplate(putTemplateRequestBuilder.request()).actionGet(); Reflections reflections = new Reflections(new ConfigurationBuilder() .setUrls(ClasspathHelper.forPackage("org.apache.streams.pojo.json")) .setScanners(new SubTypesScanner())); objectTypes = reflections.getSubTypesOf(ActivityObject.class); Path testdataDir = Paths.get("target/dependency/activitystreams-testdata"); files = Files.list(testdataDir).collect(Collectors.toList()); assert( files.size() > 0); }
Example #4
Source File: ElasticsearchReindexParentIT.java From streams with Apache License 2.0 | 5 votes |
@BeforeClass public void prepareTest() throws Exception { testConfiguration = new StreamsConfigurator<>(ElasticsearchReindexConfiguration.class).detectCustomConfiguration("ElasticsearchReindexParentIT"); testClient = ElasticsearchClientManager.getInstance(testConfiguration.getSource()).client(); ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest(); ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet(); assertThat(clusterHealthResponse.getStatus(), not(ClusterHealthStatus.RED)); IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getSource().getIndexes().get(0)); IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet(); assertTrue(indicesExistsResponse.isExists()); SearchRequestBuilder countRequest = testClient .prepareSearch(testConfiguration.getSource().getIndexes().get(0)) .setTypes(testConfiguration.getSource().getTypes().get(0)); SearchResponse countResponse = countRequest.execute().actionGet(); count = (int)countResponse.getHits().getTotalHits(); PutIndexTemplateRequestBuilder putTemplateRequestBuilder = testClient.admin().indices().preparePutTemplate("mappings"); URL templateURL = ElasticsearchParentChildWriterIT.class.getResource("/ActivityChildObjectParent.json"); ObjectNode template = MAPPER.readValue(templateURL, ObjectNode.class); String templateSource = MAPPER.writeValueAsString(template); putTemplateRequestBuilder.setSource(templateSource); testClient.admin().indices().putTemplate(putTemplateRequestBuilder.request()).actionGet(); assertThat(count, not(0)); }
Example #5
Source File: ESIntegTestCase.java From crate with Apache License 2.0 | 5 votes |
/** * Creates a randomized index template. This template is used to pass in randomized settings on a * per index basis. Allows to enable/disable the randomization for number of shards and replicas */ public void randomIndexTemplate() throws IOException { // TODO move settings for random directory etc here into the index based randomized settings. if (cluster().size() > 0) { Settings.Builder randomSettingsBuilder = setRandomIndexSettings(random(), Settings.builder()); if (isInternalCluster()) { // this is only used by mock plugins and if the cluster is not internal we just can't set it randomSettingsBuilder.put(INDEX_TEST_SEED_SETTING.getKey(), random().nextLong()); } randomSettingsBuilder.put(SETTING_NUMBER_OF_SHARDS, numberOfShards()) .put(SETTING_NUMBER_OF_REPLICAS, numberOfReplicas()); // if the test class is annotated with SuppressCodecs("*"), it means don't use lucene's codec randomization // otherwise, use it, it has assertions and so on that can find bugs. SuppressCodecs annotation = getClass().getAnnotation(SuppressCodecs.class); if (annotation != null && annotation.value().length == 1 && "*".equals(annotation.value()[0])) { randomSettingsBuilder.put("index.codec", randomFrom(CodecService.DEFAULT_CODEC, CodecService.BEST_COMPRESSION_CODEC)); } else { randomSettingsBuilder.put("index.codec", CodecService.LUCENE_DEFAULT_CODEC); } for (String setting : randomSettingsBuilder.keys()) { assertThat("non index. prefix setting set on index template, its a node setting...", setting, startsWith("index.")); } // always default delayed allocation to 0 to make sure we have tests are not delayed randomSettingsBuilder.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), 0); if (randomBoolean()) { randomSettingsBuilder.put(IndexModule.INDEX_QUERY_CACHE_ENABLED_SETTING.getKey(), randomBoolean()); } PutIndexTemplateRequestBuilder putTemplate = client().admin().indices() .preparePutTemplate("random_index_template") .setPatterns(Collections.singletonList("*")) .setOrder(0) .setSettings(randomSettingsBuilder); assertAcked(putTemplate.execute().actionGet()); } }
Example #6
Source File: AbstractClient.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public PutIndexTemplateRequestBuilder preparePutTemplate(String name) { return new PutIndexTemplateRequestBuilder(this, PutIndexTemplateAction.INSTANCE, name); }
Example #7
Source File: AbstractClient.java From crate with Apache License 2.0 | 4 votes |
@Override public PutIndexTemplateRequestBuilder preparePutTemplate(String name) { return new PutIndexTemplateRequestBuilder(this, PutIndexTemplateAction.INSTANCE, name); }
Example #8
Source File: IndicesAdminClient.java From Elasticsearch with Apache License 2.0 | 2 votes |
/** * Puts an index template. * * @param name The name of the template. */ PutIndexTemplateRequestBuilder preparePutTemplate(String name);
Example #9
Source File: IndicesAdminClient.java From crate with Apache License 2.0 | 2 votes |
/** * Puts an index template. * * @param name The name of the template. */ PutIndexTemplateRequestBuilder preparePutTemplate(String name);