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

标签 elasticsearch spring-data-elasticsearch

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 ticketOperations 中添加此功能接口(interface)和实现。

关于elasticsearch - 是否可以使用 org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate 删除索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59945886/

相关文章:

elasticsearch - 在Elasticsearch中处理可选字段搜索

laravel - 无法连接到GetCandy内的ElasticSearch

spring-mvc - 创建 bean 时出错 - 嵌套异常是 java.lang.stackoverflow 错误 spring 数据 elasticsearch 存储库

Java elasticsearch spring-data 设置不同的索引字段名称

java - 在 org.elasticsearch.client.RestHighLevelClient 中获取没有 id 的结果

elasticsearch - 如何对 Elasticsearch 中的分析字段执行完全匹配查询?

java - 加速 Elasticsearch 测试容器

ruby-on-rails - Tire/ElasticSearch 单表继承支持

elasticsearch - 我正在使用elasticsearch-1.4.1,当我尝试创建索引时,出现以下错误

Elasticsearch-hadoop & Elasticsearch-spark sql - 语句扫描和滚动的跟踪