如何在 Solr 中对组求和? [英] How to sum groups in Solr?

查看:19
本文介绍了如何在 Solr 中对组求和?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何像 solr 中的 sql 一样做到这一点?

I want to know how to do this like sql in solr ?

select sum(Col1) group by Col2,Col3

我可以在 solr 中解决像 select sum(Col1) group by Col2 这样的问题.( http://wiki.apache.org/solr/StatsComponent)你能帮助我吗 ?

I could solve the problem like select sum(Col1) group by Col2 in solr .( http://wiki.apache.org/solr/StatsComponent) can you help me ?

推荐答案

我认为你可以使用 Stats Component 您已经提到的功能.例如

I think you can achieve this using the Stats Component feature which you already mentioned. For example

/select?q=:&stats=true&stats.facet=Col2&stats.field=Col1

通过这种方式,您可以在结果中获得带有分组 Col2 的统计数据块,您可以在其中访问每个 Col2sum 值.但是文档指出不再推荐使用 stats.facet.

This way you get the stats block with a grouped Col2 in the result where you can access the sum value for each Col2. But the documentation states that the use of stats.facet is not recommended any more.

不建议新用户使用此旧参数 - 请考虑将 stats.field 与 facet.pivot 结合使用

This legacy parameter is not recommended for new users - instead please consider combining stats.field with facet.pivot

但我不得不承认,我无法仅使用推荐的 stats.field 和 facet.pivot 来解决您的用例.

But i have to admit that i fail to solve your use case using only the recommended stats.field with facet.pivot.

这篇关于如何在 Solr 中对组求和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆