简体   繁体   English

rails轮胎gem elasticsearch在will_paginate中无法正常工作

[英]rails tire gem elasticsearch not working properly with will_paginate

I'm trying to integrate Tire into my site and I'm having difficulty with pagination. 我正在尝试将Tire集成到我的网站中,但分页方面遇到困难。 I've tried paginating the results outside of the context of Tire and will_paginate is working on that Array. 我已经尝试在Tyre上下文之外对结果进行分页,而will_paginate正在对该数组进行操作。 However, when I try will_paginate within the context of Tire I'm having one large problem. 但是,当我在Tire的上下文中尝试will_paginate时,我遇到了一个大问题。

Will_Paginate will display the correct number of pages with consideration of :per_page but when I click on that page the results are not loaded, rather they are the same as on the first page. Will_Paginate将考虑: Will_Paginate来显示正确的页面数,但是当我单击该页面时,结果不会加载,而是与第一页上的结果相同。 The page number is highlighted in the will_paginate navigation. 页号在will_paginate导航中突出显示。

When I used the per_page option, I had similar issue. 当我使用per_page选项时,我遇到了类似的问题。 So, I shifted to the from size options provided by Tire. 因此,我转向了Tire提供的尺寸选项。 I'm not sure what went wrong. 我不确定出了什么问题。 But, explicitly setting and using from and size did the trick for me... 但是,显式设置from和size并使用它对我来说很成功。

 def search
    options = { :page => (params[:page] || 1), :size => 100 }
    query = params[:query]
    @results = Tire.search ['index_name'], options do
      query { string query }
      from options[:size].to_i * (options[:page].to_i-1)
    end
  end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM