获取在solr中按日期分组的唯一值

时间:2023-01-14 22:29:56

I have been struggling over a week to write a query in solr, which must return the UNIQUE value of the column actorPreferredUsernam group by postedTime.

我一直在努力在solr中编写一个查询,该查询必须通过postingTime返回列actorPreferredUsernam组的UNIQUE值。

The equivalent SQL logic is as follows

等效的SQL逻辑如下

select count(distinct actorPreferredUsernam),postedTime from tweets 
group by postedTime

I am using the new release of solr 5.1.

我正在使用solr 5.1的新版本。

1 个解决方案

#1


There are not so many details in the question. For example, is the postedTime a date field ? With which precision ? day ? hour ? ms ? in the case I find quit useless to group by dates, as we will have completely distincts groups ( depending on the precision of the date) .

问题中没有太多细节。例如,postedTime是一个日期字段吗?具有哪些精度?天 ?小时?女士 ?在我发现quit无法按日期分组的情况下,因为我们将完全区分组(取决于日期的精确度)。

Assuming we can group properly, probably I would suggest you Pivot faceting :

假设我们可以正确分组,可能我会建议你转向刻面:

https://cwiki.apache.org/confluence/display/solr/Faceting#Faceting-Pivot(DecisionTree)Faceting

Hope this helps.

希望这可以帮助。

#1


There are not so many details in the question. For example, is the postedTime a date field ? With which precision ? day ? hour ? ms ? in the case I find quit useless to group by dates, as we will have completely distincts groups ( depending on the precision of the date) .

问题中没有太多细节。例如,postedTime是一个日期字段吗?具有哪些精度?天 ?小时?女士 ?在我发现quit无法按日期分组的情况下,因为我们将完全区分组(取决于日期的精确度)。

Assuming we can group properly, probably I would suggest you Pivot faceting :

假设我们可以正确分组,可能我会建议你转向刻面:

https://cwiki.apache.org/confluence/display/solr/Faceting#Faceting-Pivot(DecisionTree)Faceting

Hope this helps.

希望这可以帮助。