[ https://issues.apache.org/jira/browse/SOLR-6354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14101572#comment-14101572 ]
Crawdaddy commented on SOLR-6354: --------------------------------- I did manage to get something working, but it has some problems. I see what you mean on the StatsValuesFactory refactor. Because I was experimenting with this in a copy of StatsComponent (which by the way, is not easy to do!), I ended up not modifying StatsValuesFactory at all. Instead, I wrote a couple inner classes extending NumericStatsValues and FieldType that take a ValueSource as input. In SimpleStats.getStatsFields() and SimpleStats.getFieldCacheStats(), I catch the exception to schema.getField() that is thrown when trying to look up non-existent function fields, and return my custom NSV/FT-based classes - stored in rb._statsInfo - instead. This seems to have broken stat faceting, however, I think since other calls to StatsValuesFactory.createStatsValues outside StatsComponent don't use the same logic. No doubt yours is the better road to travel - I was shooting for quick-n-dirty to see if this was a useful approach to a stats problem. Also, regarding changing the output key: either this was either broken already, or I broke it somehow. Would it be useful for me to upload what I have as a reference point for you or someone else to implement more coherently? I'm not sure I have the bandwidth to pull down a virgin Solr and migrate the changes at this time. > Support stats over functions > ---------------------------- > > Key: SOLR-6354 > URL: https://issues.apache.org/jira/browse/SOLR-6354 > Project: Solr > Issue Type: Sub-task > Reporter: Hoss Man > > The majority of the logic in StatsValuesFactory for dealing with stats over > fields just uses the ValueSource API. There's very little reason we can't > generalize this to support computing aggregate stats over any arbitrary > function (or the scores from an arbitrary query). > Example... > {noformat} > stats.field={!func key=mean_rating > mean=true}prod(user_rating,pow(editor_rating,2)) > {noformat} > ...would mean that we can compute a conceptual "rating" for each doc by > multiplying the user_rating field by the square of the editor_rating field, > and then we'd compute the mean of that "rating" across all docs in the set > and return it as "mean_rating" -- This message was sent by Atlassian JIRA (v6.2#6252) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org