Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to limit the total returned results when using ElasticSearch with Tire (A Ruby on Rails Gem)?

I tried to use Post.search(keyword, :size => 10) and Post.search(keyword).size(10). but non of these will work.

like image 301
silent Avatar asked Jan 12 '13 15:01

silent


1 Answers

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)
like image 157
nemesv Avatar answered Sep 24 '22 22:09

nemesv