# Fetch the document record in the same Order

**URL:** <https://discuss.elastic.co/t/fetch-the-document-record-in-the-same-order/150303>\
**Category:** Elasticsearch\
**Created:** [September 28, 2018, 7:43am UTC](https://discuss.elastic.co/t/fetch-the-document-record-in-the-same-order/150303 "2018-09-28T07:43:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dreamer2731](https://avatars.discourse-cdn.com/v4/letter/d/ac91a4/32.png) [@Dreamer2731](https://discuss.elastic.co/u/Dreamer2731)\
**Post date:** [September 28, 2018, 7:43am UTC](https://discuss.elastic.co/t/fetch-the-document-record-in-the-same-order/150303/1 "2018-09-28T07:43:17Z")

</div>

Hi,

I am trying to fetch a single document "store1" using search API preparesearch method. Below is the document data. I am getting the response into a HashMap\<String,Map\<String,String\>\>. However the problem her is the order in which the search result is populated into hashmap. It is populated in random order. i would like to get the result into hashmap in the same order as in the document i.e. (f1,f2,f3,f4,f5,f6). Is there a way to achieve this? Please help.

{  
"\_index": "store",  
"\_type": "store\_type",  
"\_id": "store1",  
"\_score": 1,  
"\_source": {  
"head": {  
"f1": {  
"val": "123",  
"size": "1"  
},  
"f2": {  
"value": "854",  
"size": "40"  
},  
"f3": {  
"value": "4545",  
"size": "13"  
},  
"f4": {  
"value": "4545",  
"size": "58"  
},  
"f5": {  
"value": "3565",  
"size": "5"  
},  
"f6": {  
"value": "8542",  
"size": "8"  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Dreamer2731](https://avatars.discourse-cdn.com/v4/letter/d/ac91a4/32.png) [@Dreamer2731](https://discuss.elastic.co/u/Dreamer2731)\
**Post date:** [October 2, 2018, 7:59am UTC](https://discuss.elastic.co/t/fetch-the-document-record-in-the-same-order/150303/2 "2018-10-02T07:59:45Z")

</div>

Can some one help me here to solve this.

---

<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:** [October 30, 2018, 7:59am UTC](https://discuss.elastic.co/t/fetch-the-document-record-in-the-same-order/150303/3 "2018-10-30T07:59:46Z")

</div>

Closed on October 30, 2018, 7:59am UTC

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