资产模型:
searchable do
text :title
text :description
time :created_at
integer :category_ids, :multiple => true, :references => Category
end
控制器:
search = Asset.search() do
keywords(h(params[:query]), :fields => [:title, :description])
facet(:category_ids)
order_by :created_at
end
我不想通过:Category_ides
(点击次数)对我的方面:count
进行排序。类别应按created_at
排序。查看文档facet(:category_ids, :sort
=> :count || :index
),这两个选项都不适用于我。
如何解决方面的此订单问题?
答案 0 :(得分:8)
您只需加载构面,然后自行对它们进行排序:
result = Product.solr_search do |s|
s.keywords params[:q]
s.facet :category_id
s.paginate :per_page => 3, :page => @page
end
facet_rows = result.facet(:category_id).rows.sort { |left,right| left.instance.created_at <=> right.instance.created_at }