-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Count total #11
Comments
Use MyIndex.where(field_id: 12).total_count |
Awesome, thanks! I tried to find anything about it in the readme, just I was looking more for |
It still doesn't work in the way I expect. irb(main):006:0> Index.range(:created_at_date, gt: date, lte: date + 1.day).total_entries
=> 10000
irb(main):007:0> Index.where(master_module_id: 12).total_entries
=> 10000
irb(main):008:0> Index.where(master_module_id: 12).total_count
=> 10000 I looked into the code and it's still doing the same search query where I want to do a count query. https://github.com/mrkamel/search_flip/blob/master/lib/search_flip/response.rb#L42 Elasticsearch (Count API) |
search flip is not using the COUNT API, because then you would always need two queries: one to get the results, and one to get the count. ES always returns 10_000, because since version 7, ES by default stops counting from 10_000 on for performance reasons. To get the exact number of results for ES > 7, you have to add Index.where(...).track_total_hits(true).total_count |
Okay, I was aware of the 10_000 limit, just not aware of the API call to make it all visible. irb(main):005:0> Index.range(:created_at_date, gt: date, lte: date + 1.day).where(master_module_id: 12).track_total_hits(true).total_count
=> 1490200 Thanks for the help again! |
I would like to do a count call and get the total amount of matching documents, problem is that search_flip is adding
size
andoffset
to all requests. Is there a way I can remove that?When I do a call like
I get the total amount in return
The text was updated successfully, but these errors were encountered: