Elasticsearch Spring Data 的 org.springframework.data.elasticsearch.core.ElasticsearchTemplate
的非响应式(Reactive)对应物提供方法public boolean deleteIndex(String indexName)
,我可以用它来删除索引。但是,我在 ReactiveElasticsearchTemplate
中找不到任何类似功能的提示。 .
最佳答案
DefaultReactiveElasticsearchClient
这是由
ReactiveRestClients.create(ClientConfiguration clientConfiguration)
实现接口(interface)
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)).
所以目前这个 Actor 阵容很难看,但可以做到。我们有a ticket在
Operations
中添加此功能接口(interface)和实现。
关于elasticsearch - 是否可以使用 org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate 删除索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59945886/