public class EsUtil{
protected boolean deleteIndies(RestHighLevelClient client, String indexName) throws IOException {
DeleteIndexRequest index = new DeleteIndexRequest(indexName);
if (existIndies(client, indexName)) {
AcknowledgedResponse delete = client.indices().delete(index, RequestOptions.DEFAULT);
return delete.isAcknowledged();
}
return false;
}
protected boolean createIndies(RestHighLevelClient client, String indexName) throws IOException {
CreateIndexRequest index = new CreateIndexRequest(indexName);
CreateIndexResponse create = client.indices().create(index, RequestOptions.DEFAULT);
return create.isAcknowledged();
}
protected boolean existIndies(RestHighLevelClient client, String indexName) throws IOException {
GetIndexRequest index = new GetIndexRequest(indexName);
return client.indices().exists(index, RequestOptions.DEFAULT);
}
}