In one of my projects, I used searchkick
gem and elasticsearch
for implementing search
feature.
Something weird happens when database records are over 10K records. The total records always show 10K, even though the actual records are 267K.
I fixed this issue by adding
body_options: { track_total_hits: true }
As an argument for the search
method.
Here is an example
collections = MyModel.pagy_search(query, fields: [:name], load: false, body_options: { track_total_hits: true })
pagy, properties = pagy_searchkick(collections)
Top comments (0)