# Collapse sort with normal sort in same query

**URL:** <https://discuss.elastic.co/t/collapse-sort-with-normal-sort-in-same-query/142391>\
**Category:** Elasticsearch\
**Created:** [July 31, 2018, 2:37pm UTC](https://discuss.elastic.co/t/collapse-sort-with-normal-sort-in-same-query/142391 "2018-07-31T14:37:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![peteratef](https://avatars.discourse-cdn.com/v4/letter/p/7c8e57/32.png) [@peteratef](https://discuss.elastic.co/u/peteratef)\
**Post date:** [July 31, 2018, 2:37pm UTC](https://discuss.elastic.co/t/collapse-sort-with-normal-sort-in-same-query/142391/1 "2018-07-31T14:37:48Z")

</div>

Dear Guys  
i am trying to make the following Query  
{  
"query": {  
"bool": {  
"must": [{ "terms":  
{  
"plugin\_name.keyword":["5b39fa87c1fb830245e83b7a", "5b3b493bc1fb8307016e045f"]  
}  
}  
],  
"filter": {  
"bool": {  
"must": []  
}  
}  
}  
},"size": 3,  
"from": 0,  
"collapse": {  
"field": "plugin\_output.plate.keyword",  
"inner\_hits": {  
"name": "latest\_record",  
"size": 1,  
"sort": [  
{  
"timestamp": "DESC"  
}  
]  
}  
},  
"sort": [  
{  
"timestamp": {  
"order": "DESC"  
}  
}  
],  
"aggs": {  
"total": {  
"cardinality": {  
"field": "plugin\_output.plate.keyword"  
}  
}  
}  
}

the problem that the collapse doesn't work successfully when the sort of timestamp of the collapse is DESC order and the sort of timestamp of the main query is ASC  
please help  
Thanks in advance

---

<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:** [August 28, 2018, 2:37pm UTC](https://discuss.elastic.co/t/collapse-sort-with-normal-sort-in-same-query/142391/2 "2018-08-28T14:37:54Z")

</div>

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