简体   繁体   English

无法在Elasticsearch中加载JavaScript脚本

[英]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_scorescript_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 谢谢

Update: 更新:

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)

Update 2: 更新2:

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.

相关问题 Ace编辑器,javascript风格:“无法加载脚本”异常 - Ace editor, javascript flavor: “Failed to load script” exception 加载模块脚本失败 - text/html 而不是 application/javascript - Failed to load module script – text/html instead of application/javascript 加载模块脚本失败:需要一个 JavaScript 模块 [vite] [react] [golang] - Failed to load module script: Expected a JavaScript module [vite] [react] [golang] 如何使用javascript动态添加脚本标签并检测脚本是否无法加载文件? - How to add a script tag dynamically using javascript and detect if the script failed to load the file? 加载模块脚本失败:应为 JavaScript 模块脚本,但服务器响应 MIME 类型为“”。 (我做了类型模块) - Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "". (I did type module) 无法加载模块脚本:需要 JavaScript 模块脚本,但服务器响应 MIME 类型为“text/html” - Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html" JavaScript中的登录脚本失败 - Login script in javascript failed 捆绑的脚本无法在浏览器中加载 - Bundled script failed to load in browser 加载脚本javascript - Load script javascript 加载模块脚本失败:服务器响应非 JavaScript MIME 类型“” - Failed to load module script: The server responded with a non-JavaScript MIME type of ""
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM