# Fetching filtered and unfiltered count in a single request

**URL:** <https://discuss.elastic.co/t/fetching-filtered-and-unfiltered-count-in-a-single-request/333160>\
**Category:** Elasticsearch\
**Created:** [May 11, 2023, 6:11am UTC](https://discuss.elastic.co/t/fetching-filtered-and-unfiltered-count-in-a-single-request/333160 "2023-05-11T06:11:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_baba](https://avatars.discourse-cdn.com/v4/letter/_/ecb155/32.png) [@\_baba](https://discuss.elastic.co/u/_baba)\
**Post date:** [May 11, 2023, 6:11am UTC](https://discuss.elastic.co/t/fetching-filtered-and-unfiltered-count-in-a-single-request/333160/1 "2023-05-11T06:11:51Z")

</div>

Hi,

I have a use case where a user\_id has multiple records in Elasticsearch. I'm using a bool query on user\_id and additional filters on top of it.

I'm able to fetch the count of filtered records using track\_total\_hits, but I'm also looking for the overall count of records for that user\_id.

Is it possible to form a single query to fetch both of these (track\_total\_hits and total record on user\_id).

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:** [June 8, 2023, 6:12am UTC](https://discuss.elastic.co/t/fetching-filtered-and-unfiltered-count-in-a-single-request/333160/2 "2023-06-08T06:12:01Z")

</div>

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