title: failed to execute script Elasticsearch
body: <p>I am trying to update the some values in a particular field, which I want to be unique. </p>
  
  <p>But when I give the script the condition .unique() it returns me an  error.</p>
  
  <p>If I do not give the condition unique then it's keep updating again and again.
  Means the value will be </p>
  
  <p>update_field= array ('world','values','frost','world','values','frost',...)</p>
  
  <p>What I am doing wrong here anyone knows !!!</p>
  
  <pre><code>        $script['script'] = 'ctx._source.update_field = (ctx._source.update_field + new_value).unique()';
          // unique() is giving the error but why
  </code></pre>
  
  <p>error message ---</p>
  
  <blockquote>
    <p>{"error":"ElasticsearchIllegalArgumentException[failed to execute
    script]; nested:
    GroovyScriptExecutionException[MissingMethodException[No signature of
    method: java.lang.String.unique() is applicable for argument types: ()
    values: []\nPossible solutions: minus(java.lang.Object),
    minus(java.util.regex.Pattern), minus(java.lang.Object), size(),
    size(), use([Ljava.lang.Object;)]]; ","status":400}</p>
  </blockquote>
  
  <p>a sample documents ---</p>
  
  <pre><code>    hits: {
          total: 19,
          max_score: 5.5197725,
          hits: [
              {
                  _index: "myIndex",
                  _type: "myType",
                  _id: "pdd9da099f380b3951a627a5d5a38758680016f16",
                  _score: 5.5197725,
                  _source: {
                      content: "After shooting attacks are several police cars sent to the streets to watch. 
                      title: "The police in Copenhagen when bødemål despite extra tasks",
                      update_field: "[funny]"
  
              }},}
  </code></pre>
  
  <p>So there you can see that the update_field is not empty and have some value -
  when when i try ---</p>
  
  <pre><code>$script['script'] = 'ctx._source.update_field = ((ctx._source.update_field ?: []) - new_value).unique()';
  </code></pre>
  
  <p>it also returns me the same error ! 
  don't know why !!</p>