# How do I get the real total when PAGING

**URL:** <https://discuss.elastic.co/t/how-do-i-get-the-real-total-when-paging/289156>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [November 15, 2021, 6:39am UTC](https://discuss.elastic.co/t/how-do-i-get-the-real-total-when-paging/289156 "2021-11-15T06:39:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![KhalidDu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/khaliddu/32/97114_2.png) [@KhalidDu](https://discuss.elastic.co/u/KhalidDu)\
**Post date:** [November 15, 2021, 6:39am UTC](https://discuss.elastic.co/t/how-do-i-get-the-real-total-when-paging/289156/1 "2021-11-15T06:39:36Z")

</div>

[When.NET](http://When.NET) uses NEST for paging query, when I get the total number of data from Hits, I find the maximum value is 10000, but my real data amount should be 50000+, I have set max\_result\_window value to 200000000, but it doesn't seem to work

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 15, 2021, 6:53am UTC](https://discuss.elastic.co/t/how-do-i-get-the-real-total-when-paging/289156/2 "2021-11-15T06:53:03Z")

</div>

Have a look at [Search your data | Elasticsearch Guide [7.15] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.15/search-your-data.html#track-total-hits)

> I have set max\_result\_window value to 200000000,

Don't do that. You are going to put a lot of pressure on the HEAP.

If you are asking about extracting all the resultset, you can use:

- the [`size` and `from` parameters](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html) to display by default up to 10000 records to your users. If you want to change this limit, you can change `index.max_result_window` setting but be aware of the consequences (ie memory).
- the [search after](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html) feature to do deep pagination.
- the [Scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html) if you want to extract a resultset to be consumed by another tool later. (Not recommended anymore)

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [November 15, 2021, 7:04am UTC](https://discuss.elastic.co/t/how-do-i-get-the-real-total-when-paging/289156/3 "2021-11-15T07:04:04Z")

</div>

If you're after just the total number of hits to be accurate, you can set [`TrackTotalHits`](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html#track-total-hits) to `true` on the search request

```auto
var client = new ElasticClient();

var searchResponse = client.Search<Data>(s => s
	.TrackTotalHits()
);

```

---

<div class="post-metadata">

**Author:** ![KhalidDu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/khaliddu/32/97114_2.png) [@KhalidDu](https://discuss.elastic.co/u/KhalidDu)\
**Post date:** [November 15, 2021, 7:14am UTC](https://discuss.elastic.co/t/how-do-i-get-the-real-total-when-paging/289156/4 "2021-11-15T07:14:35Z")

</div>

> [@forloop](#):
>
> `TrackTotalHits`

Thanks for your help, I set TrackTotalHits to True, which reached my expectation

---

<div class="post-metadata">

**Author:** ![KhalidDu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/khaliddu/32/97114_2.png) [@KhalidDu](https://discuss.elastic.co/u/KhalidDu)\
**Post date:** [November 15, 2021, 7:16am UTC](https://discuss.elastic.co/t/how-do-i-get-the-real-total-when-paging/289156/5 "2021-11-15T07:16:04Z")

</div>

Thank you for your help. I have operated according to what you said and have solved this problem. Thank you again

---

<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:** [December 13, 2021, 7:17am UTC](https://discuss.elastic.co/t/how-do-i-get-the-real-total-when-paging/289156/6 "2021-12-13T07:17:04Z")

</div>

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