[英]Failed to load javascript script in Elasticsearch
I wrote a javascript script for script_score
in function_score
, but I get the following error on elasticsearch service start. 我在
function_score
为script_score
编写了一个JavaScript脚本,但是在script_score
Service启动时出现以下错误。 I am running Ubuntu 14.04, elasticsearch 1.4.5. 我正在运行Ubuntu 14.04,elasticsearch 1.4.5。 I sadly cannot post the code here.
我可悲的是不能在这里发布代码。
What would constitute a valid return value? 什么将构成有效的返回值? Is there any way to debug the score script or print to elasticsearch logs?
有什么方法可以调试乐谱脚本或打印到Elasticsearch日志?
[2015-05-23 21:00:18,093][INFO ][script ] [Soulfire] compiling script file [/etc/elasticsearch/scripts/****.js] [2015-05-23 21:00:18,180][WARN ][script ] [Soulfire] failed to load/compile script [****] org.mozilla.javascript.EvaluatorException: invalid return (Script1.js#14)
[2015-05-23 21:00:18,093] [INFO] [脚本] [Soulfire]编译脚本文件[/etc/elasticsearch/scripts/****.js] [2015-05-23 21:00:18,180 ] [WARN] [script] [Soulfire]无法加载/编译脚本[****] org.mozilla.javascript.EvaluatorException:无效的返回值(Script1.js#14)
Thanks 谢谢
I tried a script with just return 0.5;
我尝试了一个仅
return 0.5;
的脚本return 0.5;
. 。 I still get the error:
我仍然收到错误:
[2015-05-23 22:52:48,527][INFO ][script ] [Warrior Woman] compiling script file [/etc/elasticsearch/scripts/test.js] [2015-05-23 22:52:48,609][WARN ][script ] [Warrior Woman] failed to load/compile script [test] org.mozilla.javascript.EvaluatorException: invalid return (Script1.js#1)
[2015-05-23 22:52:48,527] [INFO] [脚本] [Warrior Woman]编译脚本文件[/etc/elasticsearch/scripts/test.js] [2015-05-23 22:52:48,609] [ WARN] [脚本] [Warrior Woman]无法加载/编译脚本[test] org.mozilla.javascript.EvaluatorException:无效的返回值(Script1.js#1)
I removed the return
keyword from my script, eg: return 0;
我从脚本中删除了
return
关键字,例如: return 0;
becomes 0;
变为
0;
This results in the errors subsiding, but I continue to get unexpected results. 这导致错误消失,但是我继续得到意外的结果。 I would still like to know how I can log from within the js script.
我仍然想知道如何从js脚本中登录。
From the quick look on the log,ES is trying to say it is unable to load or compile your Javascript script.Also please add more info, if this is your dynamic script or standalone script stored in script files on host. 通过快速查看日志,ES试图说它无法加载或编译您的Javascript脚本。此外,如果这是您的动态脚本或独立脚本存储在主机的脚本文件中,请添加更多信息。 If you have't installed javascript-lang plugin for ES, there is no way ES can compile and run your Javascript.You must take a look at the following link
如果您尚未安装ES的javascript-lang插件,则ES无法编译和运行Javascript。您必须查看以下链接
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/modules-scripting.html
Even groovy is now no more sandboxed for dynamic scripting because of security concerns with ES 1.5.0 + as ES people have comeup with their own security module. 由于ES 1.5.0 +的安全性问题,现在甚至不再需要使用Groovy来进行动态脚本编写,因为ES员工已经提出了自己的安全模块。
revert back if my answer gave you any help. 如果我的回答对您有帮助,请返回。
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.