太阳黑子搜索,如何按日期返回前三篇文章?

时间:2017-12-26 18:15:02

标签: ruby-on-rails-4 solr sunspot sunspot-rails

我在我的rails应用程序中使用solr via sunspot,我希望按日期排列前3个文章,按喜欢降序排序。

我的文章表包含字段title, content, published_at, likes

可搜索区块:

searchable do
  text(:title)
  date(:published_at)
  integer(:likes)
end

数据:

title       | published_at  | likes
-------------------------------------
Article 1   | 25th Dec 2017 | 2
Article 2   | 25th Dec 2017 | 3
Article 3   | 25th Dec 2017 | 1
Article 4   | 25th Dec 2017 | 3
Article 5   | 25th Dec 2017 | 6
Article 6   | 26th Dec 2017 | 0
Article 7   | 26th Dec 2017 | 4
Article 8   | 26th Dec 2017 | 6
Article 9   | 26th Dec 2017 | 8
Article 10  | 26th Dec 2017 | 2
Article 11  | 27th Dec 2017 | 9
Article 12  | 27th Dec 2017 | 5
Article 13  | 27th Dec 2017 | 4
Article 14  | 27th Dec 2017 | 6
Article 15  | 27th Dec 2017 | 1

预期的O / P:

25th Dec

Article 5
Article 2
Article 4

26th Dec

Article 9
Article 8
Article 7

27th Dec

Article 11
Article 14
Article 12

非常感谢任何帮助。

0 个答案:

没有答案