The non-reactive counterpart of Elasticsearch Spring Data's org.springframework.data.elasticsearch.core.ElasticsearchTemplate
provides a method public boolean deleteIndex(String indexName)
, which I can use to delete indices. However, I cannot find any hints of similar functionality in the ReactiveElasticsearchTemplate
.
The DefaultReactiveElasticsearchClient
which is created by
ReactiveRestClients.create(ClientConfiguration clientConfiguration)
implements the interface org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Indices
which has two methods to delete an index:
default Mono<Void> deleteIndex(DeleteIndexRequest deleteIndexRequest) {
return deleteIndex(HttpHeaders.EMPTY, deleteIndexRequest);
}
default Mono<Void> deleteIndex(Consumer<DeleteIndexRequest> consumer) {
DeleteIndexRequest request = new DeleteIndexRequest();
consumer.accept(request);
return deleteIndex(request);
}
default Mono<Void> deleteIndex(DeleteIndexRequest deleteIndexRequest) {
return deleteIndex(HttpHeaders.EMPTY, deleteIndexRequest);
}
So nothing to pass in an index name directly, but DeleteIndexRequest
has a constructor that just takes index name(s).
((DefaultReactiveElasticsearchClient)client).deleteIndex(new DeleteIndexRequest(indexname)).
So currently it's ugly with this cast but can be done. We have a ticket to add this functionality in the Operations
interface and implementations.