# Collapse within top hit aggregation results

**URL:** <https://discuss.elastic.co/t/collapse-within-top-hit-aggregation-results/281977>\
**Category:** Elasticsearch\
**Created:** [August 19, 2021, 2:03pm UTC](https://discuss.elastic.co/t/collapse-within-top-hit-aggregation-results/281977 "2021-08-19T14:03:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhimawan](https://avatars.discourse-cdn.com/v4/letter/b/54ee81/32.png) [@bhimawan](https://discuss.elastic.co/u/bhimawan)\
**Post date:** [August 19, 2021, 2:03pm UTC](https://discuss.elastic.co/t/collapse-within-top-hit-aggregation-results/281977/1 "2021-08-19T14:03:33Z")

</div>

I'm trying to do this (two level collapse)  
 ![Screen Shot 2021-08-19 at 8.57.35 AM](https://us1.discourse-cdn.com/elastic/original/3X/0/b/0bdf204777f877bcb66bd0363ca8c5e118e99106.png)

but with top\_hits aggregation. Essentially I want to be able to have a collapse inside of the top\_hits aggregation but it's not supported.

 ![Screen Shot 2021-08-19 at 8.58.32 AM](https://us1.discourse-cdn.com/elastic/original/3X/0/0/00e16dcfb4fbd73b515b20eb3061cf016a664258.png)

Is there any way to make this work? The two level collapse works. I'm trying to see if I can get a better performance with top\_hits aggregation.

Thanks

---

<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:** [September 16, 2021, 2:03pm UTC](https://discuss.elastic.co/t/collapse-within-top-hit-aggregation-results/281977/2 "2021-09-16T14:03:47Z")

</div>

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