[英]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)
. 我尝试使用
Post.search(keyword, :size => 10)
和Post.search(keyword).size(10)
。 but non of these will work. 但这些都不起作用。
You can specify the size
option with the extended query DSL: 您可以使用扩展查询DSL指定
size
选项:
Post.search do
query { string keyword }
size 10
end
Or you can set the :per_page
option 或者您可以设置
:per_page
选项
Post.search(keyword, :per_page => 10)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.