SOLR:按日期范围筛选



我每天索引许多用户(5000万+(及其综合浏览量,例如:

{
"id": 123,
"name": "foo bar"
"views_2020_01_01": 1,
"views_2020_01_02": 2,
"views_2020_01_03": 3,
"views_2020_01_04": 4,
"otherfield": "xxx",
"yetanotherfield": "yyy",
"gimmeanotherfield": "zzz",
"otherfields.......": "....."
....
},
{
"id": 124,
"name": "bar baz"
"views_2020_01_01": 4,
"views_2020_01_02": 3,
"views_2020_01_03": 2,
"views_2020_01_04": 1,
"otherfield": "xxx",
"yetanotherfield": "yyy",
"gimmeanotherfield": "zzz",
"otherfields.......": "....."
....
}

我存储过去 2 年的视图数据。我们的网络界面可以选择日期范围(例如2019-06-012019-07-22(

在这种情况下,当我们过滤该日期范围内的show me users with more than 5 and less than 20 pageviews时,我将进行查询:

{!frange l=5 u=11} sum(views_2019-06-01,views_2019-06-02,views_2019-06-03,...,views_2019-07-22)

这是相当缓慢的。我想知道这是否只是不好的做法,或者是否有人有更好的方法来做到这一点。谢谢!

您应该有 2 个集合 1 用于用户,1 用于网页浏览量 然后使用联接查询获取数据。 看看这篇文章在 SOLR 中加入集合。

最新更新