# Automatic document creation using \_update

**URL:** <https://discuss.elastic.co/t/automatic-document-creation-using--update/7401>\
**Category:** Elasticsearch\
**Created:** [April 19, 2012, 3:48pm UTC](https://discuss.elastic.co/t/automatic-document-creation-using--update/7401 "2012-04-19T15:48:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcin\_Dojwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcin_dojwa/32/2307_2.png) [@Marcin\_Dojwa](https://discuss.elastic.co/u/Marcin_Dojwa)\
**Post date:** [April 19, 2012, 3:48pm UTC](https://discuss.elastic.co/t/automatic-document-creation-using--update/7401/1 "2012-04-19T15:48:12Z")

</div>

Hi,

Is there any possibility to create document automatically if it does not  
exist while calling \_update:  
curl -XPOST [http://localhost:9200/test/type1/1/\_update](http://localhost:9200/test/type1/1/_update) -d '{...}' ?

I do not want to check if the document '1' exists using additional  
requests to ES (e.g. curl -XGET [http://localhost:9200/test/type1/1](http://localhost:9200/test/type1/1)) if it  
is possible.

Thanks.

Best regards.  
Marcin.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 21, 2012, 11:25am UTC](https://discuss.elastic.co/t/automatic-document-creation-using--update/7401/2 "2012-04-21T11:25:46Z")

</div>

There isn't a functionality for this, though you can build it on top of it,  
i.e., send an update request, and then send an index (with create flag) to  
it if the doc is not found.

On Thu, Apr 19, 2012 at 6:48 PM, Marcin Dojwa [m.dojwa@livechatinc.com](mailto:m.dojwa@livechatinc.com)wrote:

> Hi,
> 
> Is there any possibility to create document automatically if it does not  
> exist while calling \_update:  
> curl -XPOST [http://localhost:9200/test/type1/1/\_update](http://localhost:9200/test/type1/1/_update) -d '{...}' ?
> 
> I do not want to check if the document '1' exists using additional  
> requests to ES (e.g. curl -XGET [http://localhost:9200/test/type1/1](http://localhost:9200/test/type1/1)) if it  
> is possible.
> 
> Thanks.
> 
> Best regards.  
> Marcin.

---

<div class="post-metadata">

**Author:** ![Marcin\_Dojwa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcin_dojwa/32/2307_2.png) [@Marcin\_Dojwa](https://discuss.elastic.co/u/Marcin_Dojwa)\
**Post date:** [April 21, 2012, 1:53pm UTC](https://discuss.elastic.co/t/automatic-document-creation-using--update/7401/3 "2012-04-21T13:53:33Z")

</div>

Thanks Shay.

W dniu sobota, 21 kwietnia 2012 użytkownik Shay Banon napisał:

> There isn't a functionality for this, though you can build it on top of  
> it, i.e., send an update request, and then send an index (with create flag)  
> to it if the doc is not found.
> 
> On Thu, Apr 19, 2012 at 6:48 PM, Marcin Dojwa \<[m.dojwa@livechatinc.com](mailto:m.dojwa@livechatinc.com)\<javascript:\_e({}, 'cvml', 'm.dojwa@livechatinc.com');\>
> 
> > wrote:
> 
> > Hi,
> > 
> > Is there any possibility to create document automatically if it does not  
> > exist while calling \_update:  
> > curl -XPOST [http://localhost:9200/test/type1/1/\_update](http://localhost:9200/test/type1/1/_update) -d '{...}' ?
> > 
> > I do not want to check if the document '1' exists using additional  
> > requests to ES (e.g. curl -XGET [http://localhost:9200/test/type1/1](http://localhost:9200/test/type1/1)) if  
> > it is possible.
> > 
> > Thanks.
> > 
> > Best regards.  
> > Marcin.

---

<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:31am UTC](https://discuss.elastic.co/t/automatic-document-creation-using--update/7401/4 "2017-07-06T03:31:31Z")

</div>


