# Update\_by\_query taking a partial document

**URL:** https://discuss.elastic.co/t/update-by-query-taking-a-partial-document/65940
**Category:** Elasticsearch
**Created:** [November 14, 2016, 7:26am UTC](https://discuss.elastic.co/t/update-by-query-taking-a-partial-document/65940 "2016-11-14T07:26:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Rob\_Bygrave](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rob_bygrave/32/450_2.png) [@Rob\_Bygrave](https://discuss.elastic.co/u/Rob_Bygrave)
#### Post date: [November 14, 2016, 7:26am UTC](https://discuss.elastic.co/t/update-by-query-taking-a-partial-document/65940/1 "2016-11-14T07:26:41Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Rob\_Bygrave](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rob_bygrave/32/450_2.png) [@Rob\_Bygrave](https://discuss.elastic.co/u/Rob_Bygrave)
#### Post date: [November 14, 2016, 10:39am UTC](https://discuss.elastic.co/t/update-by-query-taking-a-partial-document/65940/2 "2016-11-14T10:39:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 12, 2016, 10:40am UTC](https://discuss.elastic.co/t/update-by-query-taking-a-partial-document/65940/3 "2016-12-12T10:40:28Z")

</div>

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