JS文件脚本错误:缺少;声明前<;脚本1.js#1>;

JS文件脚本错误:缺少;声明前<;脚本1.js#1>;,
Warning: implode(): Invalid arguments passed in /data/phpspider/zhask/webroot/tpl/detail.html on line 45
,,我正在尝试使用filescript进行弹性搜索的更新操作。我正在使用的filescript是一个javascript,我无法理解为什么它的编译会失败。文件如下: update-htext.js: import org.elasticsearch.common.logging.*; var level = org.apache.log4j.Level.INFO; ESLogger logger=ESLoggerFactory.getLogger('myscript'); if(ctx._sou

我正在尝试使用filescript进行弹性搜索的更新操作。我正在使用的filescript是一个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"
    }

}
当elasticsearch启动并尝试索引此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)
…是Java导入语句,而不是JavaScript代码。在ES6之前,JavaScript没有导入;从ES6开始,它们看起来是这样的:

import myModule from "my-module.js";

哦,我从groovy代码中复制了它,但没有进行编辑,所以我想这是个问题。还有其他登录javascript的方法吗?@迷宫:取决于环境,但大多数环境都支持
console.log
。显然是弹性搜索,如班扬。
import myModule from "my-module.js";