java代码删除ElasticSearch索引

用java代码删除ElasticSearch索引

public class ElasticsearchDeleteIndexTest {
    public static void main(String[] args) throws IOException {
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(RestClient.builder(
                new HttpHost("localhost", 9200, "http")));
        try {
            DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest("user");
            AcknowledgedResponse response = restHighLevelClient.indices().
                    delete(deleteIndexRequest, RequestOptions.DEFAULT);
            System.out.println(response.isAcknowledged());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            restHighLevelClient.close();
        }
    }
}

postman验证删除后就找不到了

java代码删除ElasticSearch索引_第1张图片

 

 

你可能感兴趣的:(java,servlet,开发语言)