apache solr : sum of data resulted from group by
        Posted  
        
            by Terance Dias
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Terance Dias
        
        
        
        Published on 2010-06-03T12:50:25Z
        Indexed on 
            2010/06/03
            12:54 UTC
        
        
        Read the original article
        Hit count: 295
        
Hi,
We have a requirement where we need to group our records by a particular field and take the sum of a corresponding numeric field
e.x. select userid, sum(click_count) from user_action group by userid;
We are trying to do this using apache solr and found that there were 2 ways of doing this:
Using the field collapsing feature (http://blog.jteam.nl/2009/10/20/result-grouping-field-collapsing-with-solr/) but found 2 problems with this: 1.1. This is not part of release and is available as patch so we are not sure if we can use this in production. 1.2. We do not get the sum back but individual counts and we need to sum it at the client side.
Using the Stats Component along with faceted search (http://wiki.apache.org/solr/StatsComponent). This meets our requirement but it is not fast enough for very large data sets.
I just wanted to know if anybody knows of any other way to achieve this. Appreciate any help.
Thanks,
Terance.
© Stack Overflow or respective owner