# Order getting elements from source in query

**URL:** <https://discuss.elastic.co/t/order-getting-elements-from-source-in-query/182777>\
**Category:** Elasticsearch\
**Created:** [May 25, 2019, 10:34pm UTC](https://discuss.elastic.co/t/order-getting-elements-from-source-in-query/182777 "2019-05-25T22:34:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbalaguero](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@jbalaguero](https://discuss.elastic.co/u/jbalaguero)\
**Post date:** [May 25, 2019, 10:34pm UTC](https://discuss.elastic.co/t/order-getting-elements-from-source-in-query/182777/1 "2019-05-25T22:34:51Z")

</div>

I'm executing a query with ".../\_search?\_source=cacheId,expirationTime" and also trying "/\_search?\_source=expirationTime,cacheId", and the response is always:

( ... ) "\_source": {"expirationTime":1558724355237,"cacheId":"96|0hghj56776|13259|"} ( ... )

So, what's the order of the elements within the \_source in the response? Because it seems it's not the order requested in the query. It's important for us because we are directly "parsing" the response as string.

---

<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:** [May 25, 2019, 11:49pm UTC](https://discuss.elastic.co/t/order-getting-elements-from-source-in-query/182777/2 "2019-05-25T23:49:55Z")

</div>

You can't have it ordered. You need to read it as a json and not as a string and then do whatever ordering, transformation on your side.

---

<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 22, 2019, 11:55pm UTC](https://discuss.elastic.co/t/order-getting-elements-from-source-in-query/182777/3 "2019-06-22T23:55:31Z")

</div>

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