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.Index(FileEvent);
query.From(skip);
query.Size(take);
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());
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....
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.