是否可以使用 org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate 删除索引?

Is it possible to remove an index with org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate?

Elasticsearch Spring Data 的 org.springframework.data.elasticsearch.core.ElasticsearchTemplate 的非反应式对应物提供了一种方法 public boolean deleteIndex(String indexName),我可以使用它来删除索引。但是,我在 ReactiveElasticsearchTemplate.

中找不到任何类似功能的提示

创建的DefaultReactiveElasticsearchClient
ReactiveRestClients.create(ClientConfiguration clientConfiguration)

实现了接口org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Indices,它有两种删除索引的方法:

    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);
    }

所以没有什么可以直接传递索引名称,但是DeleteIndexRequest有一个只接受索引名称的构造函数。

((DefaultReactiveElasticsearchClient)client).deleteIndex(new DeleteIndexRequest(indexname)).

所以目前这个演员表很难看,但可以做到。我们 a ticket 可以在 Operations 接口和实现中添加此功能。