Is there any way to update multiple fields by update_by_query

Hi @tanimoto,

sure, just specify all statements in one script, i.e.:

POST /e-trend-web/items/_update_by_query
{
  "query" : {
    "bool" : {
      "filter" : {
        "terms" : {
          "_id" : [1138081, 1138083, 1138089, 123456] 
        }
      }
    }
  },
    "script" : {
      "inline" : "ctx._source.item_name= 'new_name'; ctx._source.item_price= 10000;", 
      "lang"   : "painless"
      }
  }

Note that usage of Groovy is discouraged for security reasons so I changed the scripting language to Painless (which has the same syntax for your example).

Daniel

4 Likes