1

出于某种原因,我的太阳黑子正在返回重复值。可能是什么原因?

这是我的搜索块:

@search = Item do |query|
  query.with :menu_ids, @menu.id
  query.with :public, true

  case @type
  when "popularity"
    query.order_by :popularity, :desc
  when "store"
    query.with :store_id, @stores.map(&:id)
  when "special"
    query.with :special, true
  end

  query.order_by :published_at, :desc

  if @tag
    query.fulltext @tag
  end

  query.with :price, @filters[:low]..@filters[:high] if @filters[:low] && @filters[:high]
  query.with :state, 'published'
end

@items = @search.results

我得到了 30 个项目,但其中 6 个是重复的。

4

0 回答 0