I tried to use Post.search(keyword, :size => 10)
and Post.search(keyword).size(10)
. but non of these will work.
How to limit the total returned results when using ElasticSearch with Tire (A Ruby on Rails Gem)?
Asked Answered
You can specify the size
option with the extended query DSL:
Post.search do
query { string keyword }
size 10
end
Or you can set the :per_page
option
Post.search(keyword, :per_page => 10)
© 2022 - 2024 — McMap. All rights reserved.