# Is the order of execution of requests inside bulk request is always constant?

**URL:** <https://discuss.elastic.co/t/is-the-order-of-execution-of-requests-inside-bulk-request-is-always-constant/231278>\
**Category:** Elasticsearch\
**Created:** [May 6, 2020, 6:36am UTC](https://discuss.elastic.co/t/is-the-order-of-execution-of-requests-inside-bulk-request-is-always-constant/231278 "2020-05-06T06:36:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guruprasadkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guruprasadkk/32/66271_2.png) [@guruprasadkk](https://discuss.elastic.co/u/guruprasadkk)\
**Post date:** [May 6, 2020, 6:36am UTC](https://discuss.elastic.co/t/is-the-order-of-execution-of-requests-inside-bulk-request-is-always-constant/231278/1 "2020-05-06T06:36:59Z")

</div>

If I have a document with just one field called "subject"  
and I create three update requests for same document.

update request1(with upsert as entire doc):- Creates document1 with subject "abcd"  
Update request2: Updates subject from "abcd" to "efgh"  
Update request3: Updates subject from "efgh" to "ijkl"

and create a bulk request out of this,  
Is it always executed in the same order? If at the end if I query the subject will I always get "ijkl" or is there any possibility that I will get "efgh"

Note: All these updates are for same document.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 6, 2020, 6:49am UTC](https://discuss.elastic.co/t/is-the-order-of-execution-of-requests-inside-bulk-request-is-always-constant/231278/2 "2020-05-06T06:49:57Z")

</div>

Yes, I believe the order within a bulk request will be maintained per shard. Frequently updating a single document like this will however result in worse performance as many small segments will be created, which is an expensive operation. I would recommend consolidating the update requests before sending the bulk requests.

---

<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:** [June 3, 2020, 6:50am UTC](https://discuss.elastic.co/t/is-the-order-of-execution-of-requests-inside-bulk-request-is-always-constant/231278/3 "2020-06-03T06:50:07Z")

</div>

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