# How to maintain the JSON sequence in the response from Elasctic, currently ordering is getting changed

**URL:** <https://discuss.elastic.co/t/how-to-maintain-the-json-sequence-in-the-response-from-elasctic-currently-ordering-is-getting-changed/326168>\
**Category:** Elasticsearch\
**Created:** [February 22, 2023, 11:34am UTC](https://discuss.elastic.co/t/how-to-maintain-the-json-sequence-in-the-response-from-elasctic-currently-ordering-is-getting-changed/326168 "2023-02-22T11:34:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shraddha29](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@Shraddha29](https://discuss.elastic.co/u/Shraddha29)\
**Post date:** [February 22, 2023, 11:34am UTC](https://discuss.elastic.co/t/how-to-maintain-the-json-sequence-in-the-response-from-elasctic-currently-ordering-is-getting-changed/326168/1 "2023-02-22T11:34:36Z")

</div>

How to maintain the JSON sequence in the response from Elastic, currently ordering is getting changed to what was inserted.

---

<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:** [February 22, 2023, 2:08pm UTC](https://discuss.elastic.co/t/how-to-maintain-the-json-sequence-in-the-response-from-elasctic-currently-ordering-is-getting-changed/326168/2 "2023-02-22T14:08:33Z")

</div>

The best thing to do is to rely on a field.

So I'd add a timestamp or an id and then sort on that value.

---

<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:** [March 22, 2023, 2:09pm UTC](https://discuss.elastic.co/t/how-to-maintain-the-json-sequence-in-the-response-from-elasctic-currently-ordering-is-getting-changed/326168/3 "2023-03-22T14:09:03Z")

</div>

Closed on March 22, 2023, 2:09pm UTC

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