# 7.16 Java Client - UpdateRequest example

**URL:** <https://discuss.elastic.co/t/7-16-java-client-updaterequest-example/295846>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [January 31, 2022, 1:40pm UTC](https://discuss.elastic.co/t/7-16-java-client-updaterequest-example/295846 "2022-01-31T13:40:33Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![swallez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swallez/32/11972_2.png) [@swallez](https://discuss.elastic.co/u/swallez)\
**Post date:** [January 31, 2022, 3:22pm UTC](https://discuss.elastic.co/t/7-16-java-client-updaterequest-example/295846/3 "2022-01-31T15:22:16Z")

</div>

Thanks for the feedback @ndtreviv. The update API requires an additional `Class` parameter.

The reason for this is the `source` parameter that allows retrieving the modified document. In your case you're not requesting it, so we can use the `Void` class.

Assuming the class of `document` is `SomeDoc`:

```java
client.update(new UpdateRequest.Builder<Void, SomeDoc>()
    .index(index)
    .id(id)
    .doc(document)
    .build(),
    Void.class // <-- additional parameter
);

```

You can also write it in a more compact form as:

```java
client.update(b -> b
    .index(index)
    .id(id)
    .doc(appData),
    Void.class
);

```

and similarly for the script update:

```java
client.update(u -> u
    .index(index)
    .id(id)
    .lang("painless")
    .script(s -> s
        .inline(i -> i
            .source("ctx._source.status = '"+ status +"'")
        )
    ),
    Void.class
);

```

Hope this helps. We're currently improving the docs, a section on the update request will be added there.

---

_[View the full topic](https://discuss.elastic.co/t/7-16-java-client-updaterequest-example/295846)._
