以下情况:
资产模型:
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 not via:count(点击次数).类别应按created_at排序.查看文档构面(:category_ids,:sort =>:count ||:index).两种选择都不适合我.
如何解决方面的订单问题?
解决方法
您只需加载facet,然后自己对它们进行排序:
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 }