# Issue with UpdateRequest

**URL:** <https://discuss.elastic.co/t/issue-with-updaterequest/13407>\
**Category:** Elasticsearch\
**Created:** [August 30, 2013, 10:57am UTC](https://discuss.elastic.co/t/issue-with-updaterequest/13407 "2013-08-30T10:57:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivek\_Mishra](https://avatars.discourse-cdn.com/v4/letter/v/b38774/32.png) [@Vivek\_Mishra](https://discuss.elastic.co/u/Vivek_Mishra)\
**Post date:** [August 30, 2013, 10:57am UTC](https://discuss.elastic.co/t/issue-with-updaterequest/13407/1 "2013-08-30T10:57:48Z")

</div>

Hi,  
I am struggling to get UpdateRequest working, but got stuck with this:

UpdateRequest request = new UpdateRequest("index", "type",  
"key").upsert(values);

Here, i have change values (HashMap) and tried to execute using  
BulkRequestBuilder. I am not getting any error, but it's not updating data  
as well!

Any suggestions?

-Vivek

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [August 30, 2013, 12:50pm UTC](https://discuss.elastic.co/t/issue-with-updaterequest/13407/2 "2013-08-30T12:50:58Z")

</div>

You should use the doc method instead of the upsert method. Like this:  
UpdateRequest request = new UpdateRequest("index", "type",  
"key").doc(values);

And then you can just execute it:  
UpdateResponse response = client.update(request).actionGet();

The upsert is used in the case if a document doesn't exist. Whatever has  
been specified in the upsert will be used to insert a new document.  
If the document you try to update exists, then the doc is used to merge the  
changes into the document you are updating.

On 30 August 2013 12:57, Vivek Mishra [mishra.vivs@gmail.com](mailto:mishra.vivs@gmail.com) wrote:

> Hi,  
> I am struggling to get UpdateRequest working, but got stuck with this:
> 
> UpdateRequest request = new UpdateRequest("index", "type",  
> "key").upsert(values);
> 
> Here, i have change values (HashMap) and tried to execute using  
> BulkRequestBuilder. I am not getting any error, but it's not updating data  
> as well!
> 
> Any suggestions?
> 
> -Vivek
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:18am UTC](https://discuss.elastic.co/t/issue-with-updaterequest/13407/3 "2017-07-06T02:18:47Z")

</div>


