title: remove objects from array elastic search
body: <p>I have required to remove object from array that satisfies the condition, I am able to update the object of array on the basis of condition, which is as follow:</p>
  
  <pre><code>PUT twitter/twit/1
  {"list": 
       [
          {
              "tweet_id": "1",
              "a": "b"
          },
          {
              "tweet_id": "123",
              "a": "f"
          }
      ]
  }
  
  POST /twitter/twit/1/_update
  {"script":"foreach (item :ctx._source.list) {
                  if item['tweet_id'] == tweet_id) {
                        item['new_field'] = 'ghi';
                  }
             }",
   "params": {tweet_id": 123"}
  }
  </code></pre>
  
  <p>this is working</p>
  
  <p>for remove i am doing this</p>
  
  <pre><code>POST /twitter/twit/1/_update
  { "script": "foreach (item : ctx._source.list) {
                      if item['tweet_id'] == tweet_id) {
                            ctx._source.list.remove(item); 
                      }
              }",
    "params": { tweet_id": "123" }
  }
  </code></pre>
  
  <p>but this is not working and giving this error,</p>
  
  <blockquote>
    <p>ElasticsearchIllegalArgumentException[failed to execute script];
    nested: ConcurrentModificationException; Error:
    ElasticsearchIllegalArgumentException[failed to execute script];
    nested: ConcurrentModificationException</p>
  </blockquote>
  
  <p>I am able to remove whole array or whole field using</p>
  
  <pre><code>"script": "ctx._source.remove('list')"
  </code></pre>
  
  <p>I am also able to remove object from array by specifying all the keys of an object using</p>
  
  <pre><code>"script":"ctx._source.list.remove(tag)",
       "params" : {
          "tag" : {"tweet_id": "123","a": "f"}
  </code></pre>
  
  <p>my node module elastic search version is 2.4.2 elastic search server is 1.3.2</p>