【发布时间】:2014-09-27 13:07:10
【问题描述】:
我有两个期刊模型,ClientJournal 和 InstitutionJournal,我正在使用 Sunspot 运行一个查询,该查询会抓取记录以将它们一起显示在期刊索引页面上:
search = Sunspot.search ClientJournal, InstitutionJournal do
paginate page: params[:page], per_page: 30
order_by :created_at, :desc
end
这几乎可行,但它在排序之前将结果分成两个类,因此search.results 返回如下内容:
created_at class
09:30 ClientJournal
09:12 ClientJournal
08:57 ClientJournal
07:32 ClientJournal
09:45 InstitutionJournal
09:22 InstitutionJournal
09:07 InstitutionJournal
我真正想要的是这样的:
created_at class
09:45 InstitutionJournal
09:30 ClientJournal
09:22 InstitutionJournal
09:12 ClientJournal
09:07 InstitutionJournal
08:57 ClientJournal
07:32 ClientJournal
有没有办法告诉 Sunspot 将结果排序在一起,就好像它们是同一个模型一样?
【问题讨论】:
-
你有想过这个吗?
标签: ruby-on-rails solr sunspot