Is there a way to update by Aggregation results

I'm looking to update a large amount of documents. I am able to update individual documents if I use the following script where MD51 and MD52 are the actual values that I enter.

    {
      "script": {
        "source": "ctx._source.isDupe = \"true\"",
        "lang": "painless"
      },
      "query": {
        "terms": {
        "MD5.keyword":["MD51","MD52"]
    }}}

I'd like to know if there's a way to do this from the results of an aggregation and update them all at once.

    POST testsizeindex/_update_by_query
    {
      "script": {
        "source": "ctx._source.isDupe = \"true\"",
        "lang": "painless"
      },
        "aggs": {
        "2": {
          "terms": {
            "field": "MD5_hash.keyword",
            "min_doc_count": 2
            }
          }
        }
      }

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.