# Java partial update

**URL:** https://discuss.elastic.co/t/java-partial-update/8871
**Category:** Elasticsearch
**Created:** [August 28, 2012, 2:36pm UTC](https://discuss.elastic.co/t/java-partial-update/8871 "2012-08-28T14:36:43Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![michalj](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@michalj](https://discuss.elastic.co/u/michalj)
#### Post date: [August 28, 2012, 2:36pm UTC](https://discuss.elastic.co/t/java-partial-update/8871/1 "2012-08-28T14:36:43Z")

</div>

Hi.  
I'm having some problems with partial update of documents with java api.  
When I'm using post calls documents are updated correctly.  
This how it looks in java:

```
    String id = "1";
    UpdateRequestBuilder updater = getClientToElasticSearch().prepareUpdate("test_idx", "subscriber", id);
    String script = "{\"script\":\"ctx._source.device = device\", \"params\":{\"device\":{\"brand\": \"+48123456789\",\"model\": \"+48123456789\"}}}";
    updater.setScript(script);
    updater.execute().actionGet();

```

There is no error message on this query, but data is not updated.

What's wrong with script above?

BR

I'm using ES in 0.19.8.My data:{ "device":{ "brand": "Brand 1", "model": "bRAND 2" }, "personal": { "login": "login", "firstName": "first name", "lastName": "last name", "address": "address", "zipCode": "zip code", "city": "city", "country": "COUNTRY", "language": "LanGuage" }}

--

---

<div class="post-metadata">

### Author: ![sowmyak](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@sowmyak](https://discuss.elastic.co/u/sowmyak)
#### Post date: [August 28, 2012, 2:41pm UTC](https://discuss.elastic.co/t/java-partial-update/8871/2 "2012-08-28T14:41:20Z")

</div>

Hi,

Each element should be seperated with a semicolon, but not with a comma.

On Tue, Aug 28, 2012 at 9:36 AM, misiek jendryszka [oniron9th@hotmail.com](mailto:oniron9th@hotmail.com)wrote:

> Hi.  
> I'm having some problems with partial update of documents with java api.  
> When I'm using post calls documents are updated correctly.  
> This how it looks in java:
> 
> ```
> String id = "1";
> UpdateRequestBuilder updater =
> 
> ```
> 
> getClientToElasticSearch().prepareUpdate("test\_idx", "subscriber", id);  
> String script = "{"script":"ctx.\_source.device = device",  
> "params":{"device":{"brand": "+48123456789","model": "  
> +48123456789"}}}";  
> updater.setScript(script);  
> updater.execute().actionGet();
> 
> There is no error message on this query, but data is not updated.
> 
> What's wrong with script above?
> 
> BR
> 
> I'm using ES in 0.19.8.  
> My data:  
> {  
> "device":{  
> "brand": "Brand 1",  
> "model": "bRAND 2"  
> },  
> "personal": {  
> "login": "login",  
> "firstName": "first name",  
> "lastName": "last name",  
> "address": "address",  
> "zipCode": "zip code",  
> "city": "city",  
> "country": "COUNTRY",  
> "language": "LanGuage"  
> }  
> }
> 
> --

--

---

<div class="post-metadata">

### Author: ![michalj](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@michalj](https://discuss.elastic.co/u/michalj)
#### Post date: [August 29, 2012, 7:26am UTC](https://discuss.elastic.co/t/java-partial-update/8871/3 "2012-08-29T07:26:36Z")

</div>

I'm not sure if I get You.  
After suggested change the script looks like:  
String script = "{"script":"ctx.\_source.device = device"; "params":{"device":{"brand": "+48123456789"; "model": "+48123456789"}}}";  
And still does not work.  
BR

---

<div class="post-metadata">

### Author: ![michalj](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@michalj](https://discuss.elastic.co/u/michalj)
#### Post date: [August 30, 2012, 9:32am UTC](https://discuss.elastic.co/t/java-partial-update/8871/4 "2012-08-30T09:32:52Z")

</div>

Nut this seems to work:  
String script = "ctx.\_source.device.brand = "deice";ctx.\_source.device.model = "model"";  
Thnx  
BR

---

<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: [July 6, 2017, 3:14am UTC](https://discuss.elastic.co/t/java-partial-update/8871/5 "2017-07-06T03:14:37Z")

</div>


