How to sum groups in Solr?

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

select sum(Col1) group by Col2,Col3 

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

+4
source share
2 answers

Solr provides a grouping function called the Collapsing field.
This will allow you to group in a non-ambiguous field.

+1
source

I think you can achieve this by using the Statistics Component feature that you already talked about. for instance

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

Thus, you get a statistics block with the Col2 grouping as a result, where you can access the sum value for each Col2 . But the documentation states that using stats.facet is no longer recommended.

This deprecated option is not recommended for new users - consider combining stats.field with facet.pivot instead

But I must admit that I cannot solve your use case using only the recommended stats.field with facet.pivot.

0
source

Source: https://habr.com/ru/post/1396885/


All Articles