# Collapse feature and total\_hist after collapse

**URL:** <https://discuss.elastic.co/t/collapse-feature-and-total-hist-after-collapse/333288>\
**Category:** Elasticsearch\
**Created:** [May 12, 2023, 11:12am UTC](https://discuss.elastic.co/t/collapse-feature-and-total-hist-after-collapse/333288 "2023-05-12T11:12:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_zogaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/_zogaj/32/120941_2.png) [@\_zogaj](https://discuss.elastic.co/u/_zogaj)\
**Post date:** [May 12, 2023, 11:12am UTC](https://discuss.elastic.co/t/collapse-feature-and-total-hist-after-collapse/333288/1 "2023-05-12T11:12:41Z")

</div>

As Elastisearch documantion said: The total number of hits in the response indicates the number of matching documents without collapsing. The total number of distinct group is unknown.

I am using a search with pagination and i want the exact number of total hits. I also needs to remove some duplicated stuff(i am doing it with collapse option). The problem is that i can't get the total number of hits.  
We have to mention that an aggregation with cardinality will provide wrong total hits value.  
Is there a way to get the total number of distinct group from collapse ? Is there a way(something like post\_collapse) to apply collapse option after must conditions and aggregations are calculated ? I want to get distinct doc based on a field and also the exact total value of it.  
Thank you 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:** [June 9, 2023, 11:13am UTC](https://discuss.elastic.co/t/collapse-feature-and-total-hist-after-collapse/333288/2 "2023-06-09T11:13:40Z")

</div>

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