# UPDATEs/GETs against same index and document/id guaranteed?

**URL:** <https://discuss.elastic.co/t/updates-gets-against-same-index-and-document-id-guaranteed/171424>\
**Category:** Elasticsearch\
**Created:** [March 8, 2019, 5:16am UTC](https://discuss.elastic.co/t/updates-gets-against-same-index-and-document-id-guaranteed/171424 "2019-03-08T05:16:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tregoning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tregoning/32/41692_2.png) [@tregoning](https://discuss.elastic.co/u/tregoning)\
**Post date:** [March 8, 2019, 5:16am UTC](https://discuss.elastic.co/t/updates-gets-against-same-index-and-document-id-guaranteed/171424/1 "2019-03-08T05:16:46Z")

</div>

Hi, after a lot of reading I am still not 100% clear about the following two questions:

- is the order of "update" requests (against the same index and document/id) guaranteed?

- is the order between updates/gets requests (against the same index and document/id) guaranteed?

Reduced example:

(assuming all of these are on the same index and same document/id)

- Create docA  
{  
keyA: '',  
keyB: ''  
}

* * *

- Update docA (change 'keyA' to '1')

* * *

- Update docA (change 'keyB' to '2')

* * *

- Update docA (change 'keyA' to '3')

* * *

- GET docA  
I would expect to receive the following:  
{  
keyA: '2',  
keyB: '3'  
}

* * *

- Update docA (change 'keyA' to '4')

* * *

- GET docA  
I would expect to receive the following:  
{  
keyA: '4',  
keyB: '3'  
}

Thanks!

---

<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:** [March 8, 2019, 11:25am UTC](https://discuss.elastic.co/t/updates-gets-against-same-index-and-document-id-guaranteed/171424/2 "2019-03-08T11:25:28Z")

</div>

> is the order of "update" requests (against the same index and document/id) guaranteed?

Yes if requests are sent one after the other (after the response from elasticsearch). No if they are sent in parallel (without waiting for elasticsearch response) even though one after the other.

So if you run this in Kibana (I think there was some typos in your example):

```auto
DELETE test
PUT test
PUT test/_doc/docA
{
  "keyA": "",
  "keyB": ""
}
PUT test/_doc/docA
{
  "keyA": "1",
  "keyB": ""
}
PUT test/_doc/docA
{
  "keyA": "1",
  "keyB": "2"
}
PUT test/_doc/docA
{
  "keyA": "3",
  "keyB": "2"
}
GET test/_doc/docA
PUT test/_doc/docA
{
  "keyA": "4",
  "keyB": "2"
}
GET test/_doc/docA

```

You will always get back:

```auto
# DELETE test
{
  "acknowledged" : true
}

# PUT test
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "test"
}

# PUT test/_doc/docA
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "docA",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

# PUT test/_doc/docA
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "docA",
  "_version" : 2,
  "result" : "updated",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 1,
  "_primary_term" : 1
}

# PUT test/_doc/docA
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "docA",
  "_version" : 3,
  "result" : "updated",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 2,
  "_primary_term" : 1
}

# PUT test/_doc/docA
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "docA",
  "_version" : 4,
  "result" : "updated",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 3,
  "_primary_term" : 1
}

# GET test/_doc/docA
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "docA",
  "_version" : 4,
  "_seq_no" : 3,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "keyA" : "3",
    "keyB" : "2"
  }
}

# PUT test/_doc/docA
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "docA",
  "_version" : 5,
  "result" : "updated",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 4,
  "_primary_term" : 1
}

# GET test/_doc/docA
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "docA",
  "_version" : 5,
  "_seq_no" : 4,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "keyA" : "4",
    "keyB" : "2"
  }
}

```

---

<div class="post-metadata">

**Author:** ![tregoning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tregoning/32/41692_2.png) [@tregoning](https://discuss.elastic.co/u/tregoning)\
**Post date:** [March 8, 2019, 5:36pm UTC](https://discuss.elastic.co/t/updates-gets-against-same-index-and-document-id-guaranteed/171424/3 "2019-03-08T17:36:43Z")

</div>

Thanks for the clear answer, really appreciate it. 👍

---

<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:** [April 5, 2019, 5:36pm UTC](https://discuss.elastic.co/t/updates-gets-against-same-index-and-document-id-guaranteed/171424/4 "2019-04-05T17:36:44Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
