3

我有一个带有字段的 Solr 索引:

STR(k_id)
STR(k_pid)
INT(k_count) >= 1

我想要一个实现这一点的查询:

SELECT k_pid, SUM(k_count) FROM index GROUP BY k_pid

如何对 k_count 字段进行求和运算?感谢任何帮助。

http://<myhost>:<port>/solr/collection2/select?q=*:*&debugQuery=true&fl=mk_pid,mk_id,mk_count&group=true&group.field=mk_pid
4

1 回答 1

4

You can't execute sum operations with the field collapsing (group) feature.
Use the stats component for this purpose : http://wiki.apache.org/solr/StatsComponent

于 2013-08-02T14:38:35.510 回答