Is there an api that returns how many results/logs there are based off your query search? 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.
Is there an API that will return how many results there are based your query search?
I'm not aware of any ES API that will return an exact count. At high values, it becomes very approximate.
array is empty when you paginate beyond 10,000 results.
First, returning >10k search results is highly unusual. It sounds like you're trying to use ElasticSearch as a database, which you can do for some things, but don't go depending on ACID or anything like that.
To page over large result sets in ElasticSearch, create a point in time and pass that to the search API with the search_after
parameter.