Comments (5)
Use .total_count
or .total_entries
like stated in the readme and reference docs
https://www.rubydoc.info/github/mrkamel/search_flip/SearchFlip/Response#total_entries-instance_method
MyIndex.where(field_id: 12).total_count
from search_flip.
Awesome, thanks!
I tried to find anything about it in the readme, just I was looking more for count
and total_count
is not there.
from search_flip.
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)
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html
from search_flip.
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 track_total_hits(true)
, e.g.
Index.where(...).track_total_hits(true).total_count
from search_flip.
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!
from search_flip.
Related Issues (9)
- Check if gem name is allowed HOT 4
- minimum_should_match (and boost) support on Bool Query? HOT 3
- Search pattern with colon HOT 1
- Index with document id HOT 7
- Usage with AWS Signed Requests? HOT 10
- Elasticsearch 7.11.2 `_refresh` does not support having a body (fix included) HOT 1
- AWS Signature mismatch when using special characters HOT 5
- Instrumenter configuration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from search_flip.