title: JS File script error: missing ; before statement <Script1.js#1>
body: <p>I am trying to use a filescript for an update operation for elastic search. The filescript I am using is a javascript and I am not able to understand why its compilation fails. Following is the file:</p>
  
  <p>update-htext.js:</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>And I am invoking it as follows:</p>
  
  <pre><code>{
      "script" :{  
          "script_id" : "update-htext",
          "params" : {
              "sourcehtext":{
                  "aid":1000,
                  "htext" : "and"
              }
          },
          "lang" : "javascript"
      }
  
  }
  </code></pre>
  
  <p>I get the following error when elasticsearch starts and tries to index this js file:</p>
  
  <pre><code>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)
  </code></pre>