我的应用程序使用此脚本来提升索引中最新的项目:
(5 / ((3.16*pow(10,-11)) * abs(time() - doc[\'date\'].date.getMillis()) + 0.2)) + 1.0
它是用 MVEL 编写的,但从 1.3 开始,Groovy 已弃用 MVEL。该脚本现在抛出此错误:
GroovyScriptExecutionException[MissingMethodException[No signature of method: Script4.time() is applicable for argument types: () values: []\nPossible solutions: find(), dump(), find(groovy.lang.Closure), use([Ljava.lang.Object;), is(java.lang.Object), with(groovy.lang.Closure)]]
在我看来,Groovy 中获取毫秒时间戳的函数是不同的。我试过System.currentTimeMillis()
,但它又给出了另一个错误,说它不支持导入。
那么我该如何修复time()
与 Groovy 一起使用的函数?
正如您已经发现的,您需要用 Groovy 而不是 MVEL 重写脚本。你需要使用的不是时间DateTime.now().getMillis()
。以下是如何使用它的示例:http://writequit.org/org/es/index.html#time-in-groovy-script http://writequit.org/org/es/index.html#time-in-groovy-script
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)