嘿~ 今天天气不错嘛

6x的时间计算plainless一直warning getMillisOfSecond is deprecated

Elasticsearch | 作者 God_lockin | 发布于2019年05月06日 | 阅读数:1727

最近做搜索需要加入时间衰减公式,但是会一直被ES丢warning


 returned 1 warnings: [299 Elasticsearch-6.5.2-9434bed "Use of the joda time method [getMillisOfSecond()] is deprecated. Use [get(ChronoField.MILLI_OF_SECOND)] instead." "Mon, 06 May 2019 02:32:34 GMT"]


那么问题就来了,不能这样用了```value.millisOfSecond```新版的应该怎么调用?
相关公式:
"sort": [
    {
      "_script": {
        "script": {
          "source": "1000 * 3600 * 7 * 24 * 0.8 *((1 - params.factor) * _score)/(System.currentTimeMillis() - doc['publishDate'].value.millisOfSecond + 86400000 * 7 + 1) + (1 - (1 - params.factor) * (_score))",
          "lang": "painless",
          "params": {
            "factor": 0.4
          }
        },
        "type": "number",
        "order": "desc"
      }
    }
  ]
相关ES代码
private static void logDeprecatedMethod(String oldMethod, String newMethod) {
logDeprecated(oldMethod, "Use of the joda time method [{}] is deprecated. Use [{}] instead.", oldMethod, newMethod);
}
@Deprecated
public int getMillisOfSecond() {
logDeprecatedMethod("getMillisOfSecond()", "get(ChronoField.MILLI_OF_SECOND)");
return dt.get(ChronoField.MILLI_OF_SECOND);
}
已邀请:

bellengao - 博客: https://www.jianshu.com/u/e0088e3e2127

赞同来自:

doc['x'].date.millis试试

要回复问题请先登录注册