# Update ops: doc\_as\_upsert vs upsert properties

**URL:** <https://discuss.elastic.co/t/update-ops-doc-as-upsert-vs-upsert-properties/14108>\
**Category:** Elasticsearch\
**Created:** [October 25, 2013, 8:14am UTC](https://discuss.elastic.co/t/update-ops-doc-as-upsert-vs-upsert-properties/14108 "2013-10-25T08:14:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheDeveloper](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@TheDeveloper](https://discuss.elastic.co/u/TheDeveloper)\
**Post date:** [October 25, 2013, 8:14am UTC](https://discuss.elastic.co/t/update-ops-doc-as-upsert-vs-upsert-properties/14108/1 "2013-10-25T08:14:14Z")

</div>

What's the difference between doc\_as\_upsert and upsert properties for  
updates?

Documentation  
at [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-update.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-update.html)  
seems to describe the same behaviour in different ways: that they update  
the given properties in the document if it exists in the index, or are  
indexed as the document if not.

Thanks

--  
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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [October 25, 2013, 11:50am UTC](https://discuss.elastic.co/t/update-ops-doc-as-upsert-vs-upsert-properties/14108/2 "2013-10-25T11:50:52Z")

</div>

upsert is usually used to pass an initial doc when you're using scripts to  
update.

doc\_as\_upsert is used when you're updating using a partial doc. it saves  
you from passing the doc twice: one as `doc` and once as `upsert`

clint

On 25 October 2013 10:14, Geoff Wagstaff [geoff@gosquared.com](mailto:geoff@gosquared.com) wrote:

> What's the difference between doc\_as\_upsert and upsert properties for  
> updates?
> 
> Documentation at  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-update.htmlseems) to describe the same behaviour in different ways: that they update  
> the given properties in the document if it exists in the index, or are  
> indexed as the document if not.
> 
> Thanks
> 
> --  
> 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).

--  
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:** ![TheDeveloper](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@TheDeveloper](https://discuss.elastic.co/u/TheDeveloper)\
**Post date:** [October 25, 2013, 12:41pm UTC](https://discuss.elastic.co/t/update-ops-doc-as-upsert-vs-upsert-properties/14108/3 "2013-10-25T12:41:38Z")

</div>

Hey Clint, thanks for the response.

So when updating, upsert can only be used in conjunction with a script? And  
for when you don't need a script you place your doc properties to upsert as  
doc and set doc\_as\_upsert: true?

Geoff

On Friday, October 25, 2013 12:50:52 PM UTC+1, Clinton Gormley wrote:

> upsert is usually used to pass an initial doc when you're using scripts to  
> update.
> 
> doc\_as\_upsert is used when you're updating using a partial doc. it saves  
> you from passing the doc twice: one as `doc` and once as `upsert`
> 
> clint
> 
> On 25 October 2013 10:14, Geoff Wagstaff \<[ge...@gosquared.com](mailto:ge...@gosquared.com)\<javascript:\>
> 
> > wrote:
> 
> > What's the difference between doc\_as\_upsert and upsert properties for  
> > updates?
> > 
> > Documentation at  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-update.htmlseems) to describe the same behaviour in different ways: that they update  
> > the given properties in the document if it exists in the index, or are  
> > indexed as the document if not.
> > 
> > Thanks
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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:10am UTC](https://discuss.elastic.co/t/update-ops-doc-as-upsert-vs-upsert-properties/14108/4 "2017-07-06T02:10:36Z")

</div>


