# Is there an API that will return how many logs are there

**URL:** <https://discuss.elastic.co/t/is-there-an-api-that-will-return-how-many-logs-are-there/278453>\
**Category:** Elasticsearch\
**Created:** [July 12, 2021, 6:05pm UTC](https://discuss.elastic.co/t/is-there-an-api-that-will-return-how-many-logs-are-there/278453 "2021-07-12T18:05:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoviceESCoder](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@NoviceESCoder](https://discuss.elastic.co/u/NoviceESCoder)\
**Post date:** [July 12, 2021, 6:05pm UTC](https://discuss.elastic.co/t/is-there-an-api-that-will-return-how-many-logs-are-there/278453/1 "2021-07-12T18:05:51Z")

</div>

Is there an api that returns how many results/logs there are? or like a built in feature with NEST that will tell you how many results there is like i.e. `count`? Because I have a NEST query search that will do the following:

```auto
var response = await _elasticClient.SearchAsync<EsSource>(s => s
                  .Size(3000) // must see about this
                  .Source(src => src.Includes(i => i
                                    .Fields(f => f.timestamp,
                                            fields => fields.messageTemplate,
                                            fields => fields.message)))
                  .Index("customer-simulation-es-app-logs*")
                  .Query(q => +q
                      .DateRange(dr => dr
                          .Field("@timestamp")
                              .GreaterThanOrEquals("2021-06-07T17:13:54.414-05:00")
                              .LessThanOrEquals(DateTime.Now))));

```

but I realized that the search api cannot go past 10,000 results because the array is empty when you paginate beyond 10,000 results. [search api](https://www.elastic.co/guide/en/app-search/7.13/search.html#search-api-response-body)

_So, if there is an api or a feature that will let you know how much results there is based on your index or if you are doing a monthly query search as I am above; with knowing that number I can then create a forloop to paginate through each of those documents say the first 10,0000 hits I can view then the next iteration for the next 10,000 hits and so on. Hope this makes sense, i'll clarify if needed._

---

<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:** [July 12, 2021, 7:53pm UTC](https://discuss.elastic.co/t/is-there-an-api-that-will-return-how-many-logs-are-there/278453/2 "2021-07-12T19:53:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![NoviceESCoder](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@NoviceESCoder](https://discuss.elastic.co/u/NoviceESCoder)\
**Post date:** [July 12, 2021, 8:18pm UTC](https://discuss.elastic.co/t/is-there-an-api-that-will-return-how-many-logs-are-there/278453/3 "2021-07-12T20:18:08Z")

</div>

Thank you, will do!

---

<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 9, 2021, 8:18pm UTC](https://discuss.elastic.co/t/is-there-an-api-that-will-return-how-many-logs-are-there/278453/4 "2021-08-09T20:18:28Z")

</div>

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