Pagination 10000 document total limit

I am using pagination from my .net app with nest client to just get 50 docs on each page of the grid and that works fine but the response to the search response.HitsMetadata.Total.Value is always 10000 event there are more documents.

even i am paging 50 docs I want to show the real number of documents for that search in the app so user can redefine the filters. what is wrong?

var query = new SearchDescriptor();
query.Sort(s => s.Descending(f => f.Date));

var response = await _context.ElasticClient.SearchAsync(query);
return new Tuple<long, List>(response.HitsMetadata.Total.Value, response.Documents.ToList());

You can check

Finally you can force an accurate count by setting "track_total_hits" to true in the request.

Thanks! but will this affect the performance of the query and take longer?

any idea if this affect response time of queries or no?

It will take longer as not computing the full number of hits is an optimisation that has been added.

But if you need the exact number, you need to activate this option. It's more a use case question.

For example if you are an eCommerce website and you want your users being able to search in your product catalog, telling your users that you have 123456 products matching the query or telling them that you have more than 10000 products matching is basically the same from a user and use case perspective.

If you are building a BI tool, you probably need to display exact numbers. That said, you can always have this option like a check box when you have more than 10000 saying [ ] show exact number....

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