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

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:

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

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.

Have a look at track total hits: Search your data | Elasticsearch Guide [7.13] | Elastic

1 Like

Thank you, will do!