首页 > 解决方案 > 替代 ES org.elasticsearch.action.delete.DeleteRequest 中已弃用的方法

问题描述

我使用 org.elasticsearch.client:elasticsearch-rest-high-level-client:7.13.2 作为 elasticsearch 依赖项,因为所有以前的版本都在我的组织中被隔离。

但是,由于不推荐使用的方法(如 org.elasticsearch.action.delete.DeleteRequest org.elasticsearch.action.index.IndexRequest org.elasticsearch.action.update.UpdateRequest

上述功能是否有替代方法在 ES 中创建/更新/删除文档。我确实搜索了这个主题,但找不到解决方案。

TIA

标签: elasticsearchdeprecatedelasticsearch-high-level-restclient

解决方案


据我所知,仅弃用了多个参数构造函数,仍然可以使用默认构造函数和以索引作为参数的构造函数。

    @Deprecated
    public IndexRequest(String index, String type) {
        super(NO_SHARD_ID);
        this.index = index;
        this.type = type;
    }

    
    public IndexRequest(String index) {
        super(NO_SHARD_ID);
        this.index = index;
    }

这可能是一个愚蠢的建议,但您是否尝试过使用未弃用的构造函数?


推荐阅读