# Count API with track\_total\_hits

**URL:** <https://discuss.elastic.co/t/count-api-with-track-total-hits/308912>\
**Category:** Elasticsearch\
**Created:** [July 5, 2022, 12:54pm UTC](https://discuss.elastic.co/t/count-api-with-track-total-hits/308912 "2022-07-05T12:54:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Conkling](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james_conkling/32/107927_2.png) [@James\_Conkling](https://discuss.elastic.co/u/James_Conkling)\
**Post date:** [July 5, 2022, 12:54pm UTC](https://discuss.elastic.co/t/count-api-with-track-total-hits/308912/1 "2022-07-05T12:54:07Z")

</div>

While the [search API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html) has the `track_total_hits` optimization to approximate search hit count, I noticed the [count API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html) does not.

If I am only looking for the approximate hit count, is it more performant to use the search API with `track_total_hits: 10000` and a size of 0, or use the count API and truncate the result in the client (i.e. convert anything over 10,000 to `{ value: 10000, relation: 'gte' }`).

Alternatively, is there a way to get the count API to use the `track_total_hits` param, or a reason why it does not make that optimization available?

---

<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:** [August 2, 2022, 12:54pm UTC](https://discuss.elastic.co/t/count-api-with-track-total-hits/308912/2 "2022-08-02T12:54:15Z")

</div>

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