Use Elasticsearch REST Client instead of Node client.

Closes #610
Original pull request: #612.
This commit is contained in:
Prakhar Gupta
2021-04-09 16:42:47 +05:30
committed by Mark Paluch
parent d70804b15c
commit aa95ff65a8
13 changed files with 17 additions and 330 deletions

View File

@@ -21,9 +21,11 @@ import java.io.IOException;
import java.util.Arrays;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +44,16 @@ class ApplicationConfiguration {
@Autowired ReactiveElasticsearchOperations operations;
@Autowired ConferenceRepository repository;
@PreDestroy
public void deleteIndex() {
try {
RestClients.create(ClientConfiguration.localhost()).rest().indices()
.delete(new DeleteIndexRequest("conference-index"), RequestOptions.DEFAULT);
} catch (IOException | ElasticsearchStatusException e) {
// just ignore it
}
}
@PostConstruct
public void insertDataSample() {