在ElasticSearch版本7中替换InternalSimpleValue构造函数

huangapple go评论64阅读模式
英文:

Replacing InternalSimpleValue constructor in ElasticSearch version 7

问题

我正在将ElasticSearch Java代码从5.6迁移到7.7版本。InternalSimpleValue的构造函数已从public更改为protected访问。也许Elastic有意地不向后兼容。

只是想知道是否有已知的替代方法或解决方法?其他5.6代码具有可用的替代7.7类,但似乎在InternalSimpleValue构造函数的情况下未应用此方法。

以下是5.6版本的代码片段。

import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;

@Override
public final SearchResponse execute(HttpServletRequest httpRequest, TemplateRequest request, SearchResponse response) {
    SearchResponse ret = response;
    Aggregations aggregations = response.getAggregations();
    if (null != aggregations) {
        @SuppressWarnings("unchecked") List<InternalAggregation> aggs = (List<InternalAggregation>) (List<?>) (aggregations.asList());
        // 调用实现以计算值
        Double value = buildValue(httpRequest, request, response);
        aggs.add(new InternalSimpleValue(aggregationName, value, DocValueFormat.RAW, null, null));
        // 其他操作...
    }
}
英文:

I am migrating ElasticSearch Java code from 5.6 to 7.7.
The constructor for InternalSimpleValue has been refactored from public to protected access. Perhaps Elastic are intentionally non-backward compatible.

Just wondering if there is a known replacement or workaround for this?
Other 5.6 code have alternative 7.7 classes that can be used but seemingly this approach hasn't been applied in the case of the InternalSimpleValue constructor.

Here is a code snippet of the 5.6 version.

import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;

@Override
public final SearchResponse execute(HttpServletRequest httpRequest, TemplateRequest request,     SearchResponse response) {
SearchResponse ret = response;
    Aggregations aggregations = response.getAggregations();
    if (null != aggregations) {
        @SuppressWarnings(&quot;unchecked&quot;) List&lt;InternalAggregation&gt; aggs =   (List&lt;InternalAggregation&gt;) (List&lt;?&gt;) (aggregations.asList());
        // call implementation to calculate value
        Double value = buildValue(httpRequest, request, response);
        aggs.add(new InternalSimpleValue(aggregationName, value, DocValueFormat.RAW, null, null));
	....
    }
 }

答案1

得分: 1

构造函数在此提交中被设为包级可见,时间是在2018年10月(7.0发布时),因为他们认为太多聚合类是公共的

看起来他们最近(2020年5月)在此提交中撤销了这个更改,并在7.9分支中再次将构造函数设为公共。但不幸的是,7.9尚未发布。

英文:

The constructor was made package protected in this commit in October 2018 (when 7.0 came out) because they thought too many aggregation classes were public.

It looks like they've recently (May 2020) reverted that change in this commit and made the constructor public again in the 7.9 branch. But unfortunately, 7.9 has not been released yet.

huangapple
  • 本文由 发表于 2020年7月29日 17:42:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/63150780.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定