JS文件脚本错误:缺少;before语句<Script1.js#1>
JS File script error: missing ; before statement <Script1.js#1>
我正在尝试使用一个文件脚本进行弹性搜索的更新操作。我使用的文件脚本是一个javascript,我不明白为什么它的编译失败。以下是文件:
update-htext.js:
import org.elasticsearch.common.logging.*;
var level = org.apache.log4j.Level.INFO;
ESLogger logger=ESLoggerFactory.getLogger('myscript');
if(ctx._source.hTexts == null){
ctx._source.hTexts = [sourcehtext];
return;
}else{
var i = 0;
for(it in ctx._source.hTexts){
if(it.htext.contains(sourcehtext.htext)){
logger.logger.log(level,"Already Contains "+it.htext);
return;
}
if(sourcehtext.htext.contains(it.htext)){
logger.logger.log(level,"Updating "+it.htext);
break;
}
i++;
}
ctx._source.hTexts[i] = sourcehtext;
}
我调用它如下:
{
"script" :{
"script_id" : "update-htext",
"params" : {
"sourcehtext":{
"aid":1000,
"htext" : "and"
}
},
"lang" : "javascript"
}
}
当弹性搜索开始并试图索引这个js文件时,我得到了以下错误:
org.mozilla.javascript.EvaluatorException: missing ; before statement (Script2.j
s#1)
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultError
Reporter.java:77)
at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporte
r.java:64)
import org.elasticsearch.common.logging.*;
是Java导入语句,而不是JavaScript代码。在ES6之前,JavaScript没有导入;从ES6开始,它们看起来是这样的:
import myModule from "my-module.js";
相关文章:
- 在<页眉>标签
- 如何更改<svg>标记为<img>用js标记
- Ckeditor-plugin:插入虚假元素add不情愿<p>标签前后
- Ajax文件加载和<输入>文件加载
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 链接所有<a>Meteor
- 在<输入类型=“;文件“/>
- Div根据<选择>菜单
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- 如何首先设置样式<td>表中包含在窗体中的元素
- 通过点击<李>在jQuery中
- 正在检测导航到<a name=“;最新主题”></a>
- 如何更改<选择>使用angularJS从控制器获得的值
- 通过具有IE<11
- 如何附加<ul><李>元素位于某个特定条件的父元素列表之间
- 图像可以从源<img src=""/>.TEXT可以在没有javascript的情况下从外部
- 应为标识符,而看到'<'
- 如何设置默认<ui视图>在另一<ui视图>
- 使用Javascript,如何显示<tr>在另一<tr>悬停时,隐藏第二个<tr>
- JS文件脚本错误:缺少;before语句<Script1.js#1>