How to erase ElasticSearch index?

后端 未结 4 1836
轻奢々
轻奢々 2021-02-01 16:57

My unit/integration tests includes tests for search functionality.

My idea is to have empty search index before each test. So, I\'m trying to remove al

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 17:23

    Found solution:

    IndicesAdminClient adminClient = searchConnection.client.admin().indices();
    String indexName = "location";
    DeleteIndexResponse delete = adminClient.delete(new DeleteIndexRequest(indexName)).actionGet()
    if (!delete.isAcknowledged()) {
        log.error("Index {} wasn't deleted", indexName);
    }
    

    and

    client.admin().indices().flush(new FlushRequest('location')).actionGet();
    

    after putting new data into index.

提交回复
热议问题