# Is it possible to Sort all the docs nested field together, If yes, then how

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-sort-all-the-docs-nested-field-together-if-yes-then-how/169992>\
**Category:** Elasticsearch\
**Created:** [February 26, 2019, 11:41am UTC](https://discuss.elastic.co/t/is-it-possible-to-sort-all-the-docs-nested-field-together-if-yes-then-how/169992 "2019-02-26T11:41:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PUSHKAR\_SINGH](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@PUSHKAR\_SINGH](https://discuss.elastic.co/u/PUSHKAR_SINGH)\
**Post date:** [February 26, 2019, 11:41am UTC](https://discuss.elastic.co/t/is-it-possible-to-sort-all-the-docs-nested-field-together-if-yes-then-how/169992/1 "2019-02-26T11:41:57Z")

</div>

**#Problem: we want to sort completionTimeStamp of all the docs together. Not a single document wise, but whole document wise.**

DELETE my\_index  
PUT my\_index  
{  
"mappings": {  
"doc": {  
"properties": {  
"courses": {  
"type": "nested",  
"properties": {  
"completionTimeStamp": {  
"type": "date"  
}  
}  
},  
"fullNameId": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
}  
}  
}

GET my\_index/\_mapping

PUT my\_index/doc/101  
{  
"fullNameId": "Antonio Neloms",  
"courses": [  
{  
"completionTimeStamp": "2015-02-01T08:00:00.000Z"  
},  
{  
"completionTimeStamp": "2018-06-10T08:00:00.000Z"  
}  
]  
}  
PUT my\_index/doc/102  
{  
"fullNameId": "Danny Rocks",  
"courses": [  
{  
"completionTimeStamp": "2015-08-01T08:00:00.000Z"  
},  
{  
"completionTimeStamp": "2017-06-10T08:00:00.000Z"  
}  
,  
{  
"completionTimeStamp": "2016-07-10T08:00:00.000Z"  
}  
]  
}

---

<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 26, 2019, 11:42am UTC](https://discuss.elastic.co/t/is-it-possible-to-sort-all-the-docs-nested-field-together-if-yes-then-how/169992/2 "2019-03-26T11:42:00Z")

</div>

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