# Why newly created document has version 2?

**URL:** <https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704>\
**Category:** Elasticsearch\
**Created:** [January 8, 2016, 8:57am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704 "2016-01-08T08:57:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![makeyang](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@makeyang](https://discuss.elastic.co/u/makeyang)\
**Post date:** [January 8, 2016, 8:57am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/1 "2016-01-08T08:57:47Z")

</div>

I used upsert API and print UpdateResponse

```auto
StringBuilder sb = new StringBuilder();
        sb.append("{\"_index\":\"").append(response.getIndex()).append("\",\"_type\":\"")
            .append(response.getType()).append("\",\"_id\":\"").append(response.getId())
            .append("\",\"_version\":\"").append(response.getVersion())
            .append("\",\"created\":\"").append(response.isCreated()).append("}");

```

and I found below resposne:

```auto
{"_index":"bs-list_r","_type":"list","_id":"1031438199","_version":"2","created":"true}

```

so my question is: why created doc has \_version 2?  
is it by design or is it a bug?  
if it is by design, can give more description or share some useful info please.

---

<div class="post-metadata">

**Author:** ![makeyang](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@makeyang](https://discuss.elastic.co/u/makeyang)\
**Post date:** [January 8, 2016, 9:00am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/2 "2016-01-08T09:00:48Z")

</div>

@dadoonet  
@jprante  
@nik9000  
@jpountz  
can u guys help to answer?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 8, 2016, 9:10am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/3 "2016-01-08T09:10:54Z")

</div>

Please don't ping people like this. This is so annoying.

Wait for someone to pick your question.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 8, 2016, 9:11am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/4 "2016-01-08T09:11:31Z")

</div>

Can you reproduce it with a curl script please?

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [January 8, 2016, 9:40am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/5 "2016-01-08T09:40:33Z")

</div>

See this page in the definitive guide for details on versioning: [https://www.elastic.co/guide/en/elasticsearch/guide/master/optimistic-concurrency-control.html#optimistic-concurrency-control](https://www.elastic.co/guide/en/elasticsearch/guide/master/optimistic-concurrency-control.html#optimistic-concurrency-control)

---

<div class="post-metadata">

**Author:** ![makeyang](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@makeyang](https://discuss.elastic.co/u/makeyang)\
**Post date:** [January 8, 2016, 10:09am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/6 "2016-01-08T10:09:08Z")

</div>

are u saying that I upsert data with giving certain version number? if so, I am telling u that I am not. I am not giving any version number when I upsert document. most of the docs' version is 1 when create=true, only a few with 2.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 8, 2016, 10:38am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/7 "2016-01-08T10:38:07Z")

</div>

That's why

> Can you reproduce it with a curl script please?

would help a lot to see if it's actually an issue...

---

<div class="post-metadata">

**Author:** ![makeyang](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@makeyang](https://discuss.elastic.co/u/makeyang)\
**Post date:** [January 8, 2016, 11:15am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/8 "2016-01-08T11:15:41Z")

</div>

I create a script and all response turns out to be "\_version":1

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 8, 2016, 11:33am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/9 "2016-01-08T11:33:40Z")

</div>

It means you are may be doing something wrong in the other code or you did change a document which was already existing...

---

<div class="post-metadata">

**Author:** ![makeyang](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@makeyang](https://discuss.elastic.co/u/makeyang)\
**Post date:** [January 10, 2016, 12:26am UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/10 "2016-01-10T00:26:29Z")

</div>

you are damn right.but what exactly something wrong is? isn't server should response for this some way?

---

<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 5, 2017, 11:25pm UTC](https://discuss.elastic.co/t/why-newly-created-document-has-version-2/38704/11 "2017-07-05T23:25:43Z")

</div>


