# Collapse in In-group and out-of-group sorting problem

**URL:** https://discuss.elastic.co/t/collapse-in-in-group-and-out-of-group-sorting-problem/307378
**Category:** Elasticsearch
**Created:** [June 16, 2022, 10:01am UTC](https://discuss.elastic.co/t/collapse-in-in-group-and-out-of-group-sorting-problem/307378 "2022-06-16T10:01:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![EaChou](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eachou/32/107115_2.png) [@EaChou](https://discuss.elastic.co/u/EaChou)
#### Post date: [June 16, 2022, 10:01am UTC](https://discuss.elastic.co/t/collapse-in-in-group-and-out-of-group-sorting-problem/307378/1 "2022-06-16T10:01:57Z")

</div>

I want to group by a certain field, take only one of each group, and then sort by this document outside the group

I used collapse to group and deduplicate, but after deduplication, it is not the first result after sorting in inner\_hits

---

<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: [July 14, 2022, 10:02am UTC](https://discuss.elastic.co/t/collapse-in-in-group-and-out-of-group-sorting-problem/307378/2 "2022-07-14T10:02:45Z")

</div>

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