org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse Java Examples
The following examples show how to use
org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse.
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 deleteIndex(List<String> indices, DeleteIndexOptions options, Handler<AsyncResult<Void>> resultHandler) { final DeleteIndexRequestBuilder builder = new DeleteIndexRequestBuilder(service.getClient(), DeleteIndexAction.INSTANCE, indices.toArray(new String[0])); builder.execute(new ActionListener<DeleteIndexResponse>() { @Override public void onResponse(DeleteIndexResponse deleteIndexResponse) { resultHandler.handle(Future.succeededFuture()); } @Override public void onFailure(Exception e) { resultHandler.handle(Future.failedFuture(e)); } }); }
Example #2
Source File: IndexController.java From blog-sample with Apache License 2.0 | 6 votes |
/** * 删除索引 * @param index 索引名 * @author jitwxs * @since 2018/10/9 15:08 */ @DeleteMapping("/index/delete/{index}") public ResultBean deleteIndex(@PathVariable String index) { if (StringUtils.isBlank(index)) { return ResultBean.error("参数错误,索引为空!"); } try { // 删除索引 DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(index); DeleteIndexResponse response = transportClient.admin().indices().delete(deleteIndexRequest).get(); logger.info("删除索引结果:{}",response.isAcknowledged()); return ResultBean.success("删除索引成功!"); } catch (Exception e) { logger.error("删除索引失败!要删除的索引为{},异常为:",index,e.getMessage(),e); return ResultBean.error("删除索引失败!"); } }
Example #3
Source File: AbstractEsTest.java From test-data-generator with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { if (client.admin().indices().prepareExists(getIndexName()).execute().actionGet().isExists()) { DeleteIndexResponse deleteIndexResponse = client.admin().indices().prepareDelete(getIndexName()) .execute().actionGet(); Assert.assertTrue(deleteIndexResponse.isAcknowledged()); } CreateIndexResponse createIndexResponse = client.admin().indices().prepareCreate(getIndexName()) .execute().actionGet(); Assert.assertTrue(createIndexResponse.isAcknowledged()); for (Map.Entry<String, String> esMapping : getEsMappings().entrySet()) { String esMappingSource = IOUtils.toString( AbstractEsTest.class.getClassLoader().getResourceAsStream(esMapping.getValue())); PutMappingResponse putMappingResponse = client.admin().indices().preparePutMapping(getIndexName()) .setType(esMapping.getKey()).setSource(esMappingSource).execute().actionGet(); Assert.assertTrue(putMappingResponse.isAcknowledged()); } }
Example #4
Source File: TwitterHistoryElasticsearchIT.java From streams with Apache License 2.0 | 6 votes |
@BeforeClass public void prepareTest() throws Exception { testConfiguration = new StreamsConfigurator<>(TwitterHistoryElasticsearchConfiguration.class).detectCustomConfiguration(); testClient = ElasticsearchClientManager.getInstance(testConfiguration.getElasticsearch()).client(); ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest(); ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet(); assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED); IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getElasticsearch().getIndex()); IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet(); if(indicesExistsResponse.isExists()) { DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(testConfiguration.getElasticsearch().getIndex()); DeleteIndexResponse deleteIndexResponse = testClient.admin().indices().delete(deleteIndexRequest).actionGet(); assertTrue(deleteIndexResponse.isAcknowledged()); }; }
Example #5
Source File: TableCreator.java From Elasticsearch with Apache License 2.0 | 6 votes |
private void deleteOrphans(final CreateTableResponseListener listener, final CreateTableAnalyzedStatement statement) { if (clusterService.state().metaData().hasAlias(statement.tableIdent().fqn()) && PartitionName.isPartition( clusterService.state().metaData().getAliasAndIndexLookup().get(statement.tableIdent().fqn()).getIndices().iterator().next().getIndex())) { logger.debug("Deleting orphaned partitions with alias: {}", statement.tableIdent().fqn()); transportActionProvider.transportDeleteIndexAction().execute(new DeleteIndexRequest(statement.tableIdent().fqn()), new ActionListener<DeleteIndexResponse>() { @Override public void onResponse(DeleteIndexResponse response) { if (!response.isAcknowledged()) { warnNotAcknowledged("deleting orphaned alias"); } deleteOrphanedPartitions(listener, statement.tableIdent()); } @Override public void onFailure(Throwable e) { listener.onFailure(e); } }); } else { deleteOrphanedPartitions(listener, statement.tableIdent()); } }
Example #6
Source File: TableCreator.java From Elasticsearch with Apache License 2.0 | 6 votes |
/** * if some orphaned partition with the same table name still exist, * delete them beforehand as they would create unwanted and maybe invalid * initial data. * * should never delete partitions of existing partitioned tables */ private void deleteOrphanedPartitions(final CreateTableResponseListener listener, TableIdent tableIdent) { String partitionWildCard = PartitionName.templateName(tableIdent.schema(), tableIdent.name()) + "*"; String[] orphans = indexNameExpressionResolver.concreteIndices(clusterService.state(), IndicesOptions.strictExpand(), partitionWildCard); if (orphans.length > 0) { if (logger.isDebugEnabled()) { logger.debug("Deleting orphaned partitions: {}", Joiner.on(", ").join(orphans)); } transportActionProvider.transportDeleteIndexAction().execute(new DeleteIndexRequest(orphans), new ActionListener<DeleteIndexResponse>() { @Override public void onResponse(DeleteIndexResponse response) { if (!response.isAcknowledged()) { warnNotAcknowledged("deleting orphans"); } listener.onResponse(SUCCESS_RESULT); } @Override public void onFailure(Throwable e) { listener.onFailure(e); } }); } else { listener.onResponse(SUCCESS_RESULT); } }
Example #7
Source File: HdfsElasticsearchIT.java From streams with Apache License 2.0 | 6 votes |
@BeforeClass public void prepareTest() throws Exception { testConfiguration = new StreamsConfigurator<>(HdfsElasticsearchConfiguration.class).detectCustomConfiguration("HdfsElasticsearchIT"); testClient = ElasticsearchClientManager.getInstance(testConfiguration.getDestination()).client(); ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest(); ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet(); assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED); IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getDestination().getIndex()); IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet(); if(indicesExistsResponse.isExists()) { DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(testConfiguration.getDestination().getIndex()); DeleteIndexResponse deleteIndexResponse = testClient.admin().indices().delete(deleteIndexRequest).actionGet(); assertTrue(deleteIndexResponse.isAcknowledged()); }; }
Example #8
Source File: TwitterUserstreamElasticsearchIT.java From streams with Apache License 2.0 | 6 votes |
@BeforeClass public void prepareTest() throws Exception { testConfiguration = new StreamsConfigurator<>(TwitterUserstreamElasticsearchConfiguration.class).detectCustomConfiguration(); testClient = ElasticsearchClientManager.getInstance(testConfiguration.getElasticsearch()).client(); ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest(); ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet(); assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED); IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getElasticsearch().getIndex()); IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet(); if(indicesExistsResponse.isExists()) { DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(testConfiguration.getElasticsearch().getIndex()); DeleteIndexResponse deleteIndexResponse = testClient.admin().indices().delete(deleteIndexRequest).actionGet(); assertTrue(deleteIndexResponse.isAcknowledged()); }; CreateIndexRequest createIndexRequest = Requests.createIndexRequest(testConfiguration.getElasticsearch().getIndex()); CreateIndexResponse createIndexResponse = testClient.admin().indices().create(createIndexRequest).actionGet(); assertTrue(createIndexResponse.isAcknowledged()); }
Example #9
Source File: ElasticSearchPercolateTest.java From attic-apex-malhar with Apache License 2.0 | 6 votes |
@After public void cleanup() throws IOException { try { DeleteIndexResponse delete = store.client.admin().indices().delete(new DeleteIndexRequest(INDEX_NAME)).actionGet(); if (!delete.isAcknowledged()) { logger.error("Index wasn't deleted"); } store.disconnect(); } catch (NoNodeAvailableException e) { //This indicates that elasticsearch is not running on a particular machine. //Silently ignore in this case. } }
Example #10
Source File: ElasticsearchPersistWriterIT.java From streams with Apache License 2.0 | 6 votes |
@BeforeClass public void prepareTestPersistWriter() throws Exception { testConfiguration = new ComponentConfigurator<>(ElasticsearchWriterConfiguration.class).detectConfiguration("ElasticsearchPersistWriterIT"); 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()); } }
Example #11
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 #12
Source File: ElasticBulkService.java From mongolastic with MIT License | 5 votes |
@Override public void dropDataSet() { final String indexName = config.getMisc().getDindex().getAs(); IndicesAdminClient admin = client.getClient().admin().indices(); IndicesExistsRequestBuilder builder = admin.prepareExists(indexName); if (builder.execute().actionGet().isExists()) { DeleteIndexResponse delete = admin.delete(new DeleteIndexRequest(indexName)).actionGet(); if (delete.isAcknowledged()) logger.info(String.format("The current index %s was deleted.", indexName)); else logger.info(String.format("The current index %s was not deleted.", indexName)); } }
Example #13
Source File: ElasticSearchClient.java From skywalking with Apache License 2.0 | 5 votes |
protected boolean deleteIndex(String indexName, boolean formatIndexName) throws IOException { if (formatIndexName) { indexName = formatIndexName(indexName); } DeleteIndexRequest request = new DeleteIndexRequest(indexName); DeleteIndexResponse response; response = client.indices().delete(request); log.debug("delete {} index finished, isAcknowledged: {}", indexName, response.isAcknowledged()); return response.isAcknowledged(); }
Example #14
Source File: EsIndexImpl.java From io with Apache License 2.0 | 5 votes |
@Override DeleteIndexResponse onParticularError(ElasticsearchException e) { if (e instanceof IndexNotFoundException || e.getCause() instanceof IndexNotFoundException) { throw new EsClientException.EsIndexMissingException(e); } throw e; }
Example #15
Source File: EsIndexImpl.java From io with Apache License 2.0 | 5 votes |
@Override DeleteIndexResponse onParticularError(ElasticsearchException e) { if (e instanceof IndexMissingException || e.getCause() instanceof IndexMissingException) { throw new EsClientException.EsIndexMissingException(e); } throw e; }
Example #16
Source File: TransportWriterVariant.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@Override public TestClient getTestClient(Config config) throws IOException { final ElasticsearchTransportClientWriter transportClientWriter = new ElasticsearchTransportClientWriter(config); final TransportClient transportClient = transportClientWriter.getTransportClient(); return new TestClient() { @Override public GetResponse get(GetRequest getRequest) throws IOException { try { return transportClient.get(getRequest).get(); } catch (Exception e) { throw new IOException(e); } } @Override public void recreateIndex(String indexName) throws IOException { DeleteIndexRequestBuilder dirBuilder = transportClient.admin().indices().prepareDelete(indexName); try { DeleteIndexResponse diResponse = dirBuilder.execute().actionGet(); } catch (IndexNotFoundException ie) { System.out.println("Index not found... that's ok"); } CreateIndexRequestBuilder cirBuilder = transportClient.admin().indices().prepareCreate(indexName); CreateIndexResponse ciResponse = cirBuilder.execute().actionGet(); Assert.assertTrue(ciResponse.isAcknowledged(), "Create index succeeeded"); } @Override public void close() throws IOException { transportClientWriter.close(); } }; }
Example #17
Source File: ElasticsearchIndexManager.java From Raigad with Apache License 2.0 | 5 votes |
void deleteIndices(Client client, String indexName, int timeout) { DeleteIndexResponse deleteIndexResponse = client.admin().indices().prepareDelete(indexName).execute().actionGet(timeout); if (deleteIndexResponse.isAcknowledged()) { logger.info(indexName + " deleted"); } else { logger.warn("Failed to delete " + indexName); throw new RuntimeException("Failed to delete " + indexName); } }
Example #18
Source File: IndexUtils.java From search-spring-boot-starter with Apache License 2.0 | 5 votes |
public static boolean deleteIndex(Client client, String index) throws InterruptedException, ExecutionException { if (isExistsIndex(client, index)) { DeleteIndexResponse deleteResponse = client.admin().indices().delete(new DeleteIndexRequest(index)).get(); return deleteResponse.isAcknowledged(); } else { return false; } }
Example #19
Source File: ElasticsearchTestUtils.java From foxtrot with Apache License 2.0 | 5 votes |
public static void cleanupIndices(final ElasticsearchConnection elasticsearchConnection) { try { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest("_all"); final DeleteIndexResponse deleteIndexResponse = elasticsearchConnection.getClient() .admin() .indices() .delete(deleteIndexRequest) .get(); log.info("Delete index response: {}", deleteIndexResponse); } catch (Exception e) { log.error("Index Cleanup failed", e); } }
Example #20
Source File: TransportClient.java From elasticsearch-jest-example with MIT License | 5 votes |
/** * 删除所有索引 * @param indices */ private static void deleteIndices(String indices){ Client client = createTransportClient(); DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indices); DeleteIndexResponse response = client.admin().indices().delete(deleteIndexRequest) .actionGet(); if(response.isAcknowledged()){ System.out.println("删除成功!"); // FlushRequest flushRequest = new FlushRequest(indices); // flushRequest.force(true); // FlushResponse flushResponse = client.admin().indices().flush(flushRequest).actionGet(); // System.out.println(flushResponse.getTotalShards()+","+flushResponse.getSuccessfulShards()+","+flushResponse.getFailedShards()); } }
Example #21
Source File: DeleteIndexRequestBuilder.java From elasticshell with Apache License 2.0 | 5 votes |
@Override protected XContentBuilder toXContent(DeleteIndexRequest request, DeleteIndexResponse response, XContentBuilder builder) throws IOException { return builder.startObject() .field(Fields.OK, true) .field(Fields.ACKNOWLEDGED, response.isAcknowledged()) .endObject(); }
Example #22
Source File: ElasticsearchResource.java From newsleak with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates a new elasticsearch index and adds a mapping for the document type. * Previously existing indexes will be removed. * * @throws Exception * the exception */ private void createIndex() throws Exception { boolean exists = client.admin().indices().prepareExists(mIndex).execute().actionGet().isExists(); // remove preexisting index if (exists) { logger.log(Level.INFO, "Preexisting index " + mIndex + " will be removed."); DeleteIndexResponse deleteResponse = client.admin().indices().delete(new DeleteIndexRequest(mIndex)) .actionGet(); if (deleteResponse.isAcknowledged()) { logger.log(Level.INFO, "Preexisting index " + mIndex + " successfully removed."); exists = false; } } // create schema mapping from file logger.log(Level.INFO, "Index " + mIndex + " will be created."); String docMapping = new String(Files.readAllBytes(Paths.get(documentMappingFile))); XContentBuilder builder = XContentFactory.jsonBuilder(); XContentParser parser = XContentFactory.xContent(XContentType.JSON).createParser(docMapping.getBytes()); parser.close(); builder.copyCurrentStructure(parser); CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(mIndex); createIndexRequestBuilder.addMapping(DOCUMENT_TYPE, builder); createIndexRequestBuilder.execute().actionGet(); }
Example #23
Source File: ElasticsearchUtil.java From SpringBootLearn with Apache License 2.0 | 5 votes |
/** * 删除索引 * @param index * @return */ public static boolean deleteIndex(String index) { if (!isIndexExist(index)) { log.info("Index is not exits!"); } DeleteIndexResponse dResponse = client.admin().indices().prepareDelete(index).execute().actionGet(); if (dResponse.isAcknowledged()) { log.info("delete index " + index + " successfully!"); } else { log.info("Fail to delete index " + index); } return dResponse.isAcknowledged(); }
Example #24
Source File: ESOpt.java From common-project with Apache License 2.0 | 5 votes |
/** * 删除索引 * @param index * @return */ public static boolean deleteIndex(String index) { if (!isIndexExist(index)) { logger.info("Index is not exits!"); } DeleteIndexResponse dResponse = client.admin().indices().prepareDelete(index).execute().actionGet(); if (dResponse.isAcknowledged()) { logger.info("delete index " + index + " successfully!"); } else { logger.info("Fail to delete index " + index); } return dResponse.isAcknowledged(); }
Example #25
Source File: DropTableTask.java From Elasticsearch with Apache License 2.0 | 5 votes |
private void deleteESIndex(String indexOrAlias) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexOrAlias); deleteIndexRequest.putHeader(LoginUserContext.USER_INFO_KEY, this.getParamContext().getLoginUserContext()); if (tableInfo.isPartitioned()) { deleteIndexRequest.indicesOptions(IndicesOptions.lenientExpandOpen()); } deleteIndexAction.execute(deleteIndexRequest, new ActionListener<DeleteIndexResponse>() { @Override public void onResponse(DeleteIndexResponse response) { if (!response.isAcknowledged()) { warnNotAcknowledged(String.format(Locale.ENGLISH, "dropping table '%s'", tableInfo.ident().fqn())); } result.set(SUCCESS_RESULT); } @Override public void onFailure(Throwable e) { if (tableInfo.isPartitioned()) { logger.warn("Could not (fully) delete all partitions of {}. " + "Some orphaned partitions might still exist, " + "but are not accessible.", e, tableInfo.ident().fqn()); } if (ifExists && e instanceof IndexNotFoundException) { result.set(TaskResult.ZERO); } else { result.setException(e); } } }); }
Example #26
Source File: RestDeleteIndexAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(Strings.splitStringByCommaToArray(request.param("index"))); deleteIndexRequest.timeout(request.paramAsTime("timeout", deleteIndexRequest.timeout())); deleteIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexRequest.masterNodeTimeout())); deleteIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, deleteIndexRequest.indicesOptions())); client.admin().indices().delete(deleteIndexRequest, new AcknowledgedRestListener<DeleteIndexResponse>(channel)); }
Example #27
Source File: ESUpdateState.java From sql4es with Apache License 2.0 | 5 votes |
/** * Deletes the INDEX with the specified name * @param sql * @param drop * @return * @throws SQLException */ public int execute(String sql, DropTable drop) throws SQLException { String index = drop.getTableName().toString(); index = Heading.findOriginal(sql.trim()+";", index, "table\\s+",";"); DeleteIndexResponse response = client.admin().indices().prepareDelete(index).execute().actionGet(); if(!response.isAcknowledged()) throw new SQLException("Elasticsearch failed to delete the specified index"); return 0; }
Example #28
Source File: EsRetryTest.java From io with Apache License 2.0 | 4 votes |
@Override public ActionFuture<DeleteIndexResponse> deleteIndex(String index) { throwException(); return super.deleteIndex(index); }
Example #29
Source File: DeleteIndexRequestBuilder.java From elasticshell with Apache License 2.0 | 4 votes |
@Override protected ActionFuture<DeleteIndexResponse> doExecute(DeleteIndexRequest request) { return client.admin().indices().delete(request); }
Example #30
Source File: ESConnector.java From Siamese with GNU General Public License v3.0 | 4 votes |
public boolean deleteIndex(String indexName) { DeleteIndexRequest deleteRequest = new DeleteIndexRequest(indexName); DeleteIndexResponse response = client.admin().indices().delete(deleteRequest).actionGet(); return response.isAcknowledged(); }