Update_by_query taking a partial document

Hi,
I'm looking to use update_by_query with something like:

{
"script": {
    "inline": "ctx._source.customer.name='Rob'; ctx._source.customer.billingAddress.line1='42 foo way'; ctx._source.customer.billingAddress.line2='Niceplace'; ",
    "lang": "painless"
  },

"query":{"bool":{"filter":{"term":{"customer.id":"42"}}}}
}

When the number of "properties/paths" that need to be updated increases this starts to look messy. I realise that an alternative is to create an _ingest pipeline with a list of "set field value" processors but then that seems more chatty and painful (create the pipeline, perform the upate_by_query, delete the pipeline).

What I'd like / expect is to be able to provide the list of processors to the update_by_query rather than using a script or even better provide a partial document.

Are these options available for update_by_query? Or is there any plan/request to add this type of feature?

Thanks, Rob.

It seems you can do something like:

{
  "query": {
    "bool": {
      "filter": {
        "term": {
          "customer.id": "2"
        }
      }
    }
  },
  "script": {
    "lang": "painless",
    "inline": "ctx._source.customer = params.customer",
    "params": {
      "customer": {
        "id": 2,
        "name": "CustJ4",
        "anotherProperty" : {
          "foo" :123,
          "baz" : true
        }
      }
    }
  }
}

Which overrides the embedded/nested document (although this approach isn't documented so it's not clear if it is an officially supported approach).

It would be nice to be able to do a partial document update in a similar manor (without the complete override). Anyone got anything to say on this?

Thanks, Rob.

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