title: How remove an element in all documents of an index in elasticsearch?
body: <p>I have list of documents in an index of Elasticsearch like below:</p>
  <pre><code>...
  {
    &quot;_index&quot; : &quot;index-name&quot;,
    &quot;_type&quot; : &quot;_doc&quot;,
    &quot;_id&quot; : &quot;table1c7151240c583e60c8e2cbad351&quot;,
    &quot;_score&quot; : 0.28322574,
    &quot;_source&quot; : {
      ...
      &quot;table.tag&quot; : {
        &quot;datasources_keys&quot; : [...],
        &quot;tags&quot; : [
          &quot;6e7358e2bfc84c34af32a01f6d19e9b2&quot;,
          &quot;ab450ae5c1734fb0aad5fed052b42023&quot;,
          &quot;f725e3100bba4b5eb8a5199a2b3e62fc&quot;
        ]
      }
    }
  },
  ...
  </code></pre>
  <p>I wanna delete an element in all documents.. for example should remove a specified <code>tag_id</code> in <code>tags</code> like <code>&quot;6e7358e2bfc84c34af32a01f6d19e9b2&quot;</code> .. how should I write a script for that? Is there other way in elasticsearch?</p>
  <p>I'm using this script.. but it doesnt work!!</p>
  <pre><code>POST index-name/_update_by_query
  {
    &quot;query&quot;: {
      &quot;match&quot;:{
        &quot;table.tag.tags&quot;: &quot;6e7358e2bfc84c34af32a01f6d19e9b2&quot;
      }
    },
    &quot;script&quot;: {
      &quot;source&quot;: &quot;ctx._source['table.tag']['tags'] -= 6e7358e2bfc84c34af32a01f6d19e9b2&quot;,
      &quot;lang&quot;: &quot;painless&quot;
    }
  }
  </code></pre>