I want to know how to do this like sql in solr ?
select sum(Col1) group by Col2,Col3
I could solve the problem like select sum(Col1) gr
Solr provides an grouping feature called field Collapsing
This will allow you to group on a non multivalued field.
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
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.
This legacy parameter is not recommended for new users - instead please consider combining stats.field with facet.pivot
But i have to admit that i fail to solve your use case using only the recommended stats.field with facet.pivot.