: However, I need to do able to divide certain metrics. I tried including : functions in the stats.field such as div(sum(bounce_rate), (sum(visits)) but : it doesn't recognize the functions. Also it seems to ignoring the paging for : the stats results and returns all groups regardless.
i'm lost on what your goal is regarding grouping and what you mean by "ignoring the paging" but FWIW stats.field does support functions (or query scores) -- you just need to use local params to make it clear that you are passing in a function name and not a field name... https://cwiki.apache.org/confluence/display/solr/The+Stats+Component Example... http://localhost:8983/solr/techproducts/select?q=*:*&stats=true&stats.field={!func}termfreq('text','memory')&stats.field=price&stats.field=popularity&rows=0&indent=true : Ultimately I'd like something like this which is what I would get in SQL: : <http://lucene.472066.n3.nabble.com/file/n4211402/pic.png> at first glance, making some assumptions about your data, this looks like pivot faceting with some stats hanging off of it -- ie: facet.pivot={!stats=nest}site_id,keyword stats.field={!tag=nest sum=true}visits stats.field={!tag=nest sum=true}bounces stats.field={!tag=nest sum=true}pageviews https://cwiki.apache.org/confluence/display/solr/Faceting#Faceting-CombiningStatsComponentWithPivots ...that will give you the sum or each of the specified fields for each "top" keyword (by doc count) for each "top" site_id (by doc count). (Computing the bounce_rate and avg_pages_per_visit is simple client side division) : - Paging is ignored for stats data How/Why exactly do you want/expect paging to affect stats computation? stats are over entire result sets -- if you wnated stats just over a single page that's trivial to do in the client. : - I can't figure out how to divide two stats together to get a third stat. : Note: In some cases I would need to be able to sort on this combined stat Yeah, unfortunately sorting pivots facet results currently only works by either hte doc count or the term, not an arbitrary stat on the docs in the pivot subset (that's a really hard problem to solve for arbitrary functions in a distributed setup) ... the new JSON faceting stuff might do what you want, but i don't really know enough about it to say... https://cwiki.apache.org/confluence/display/solr/JSON+Request+API -Hoss http://www.lucidworks.com/