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

1

7

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

Hughes answered 12/1, 2013 at 15:33 Comment(0)
S
14

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)
Sandoval answered 12/1, 2013 at 15:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.