[ 
https://issues.apache.org/jira/browse/SOLR-6354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14101414#comment-14101414
 ] 

Hoss Man commented on SOLR-6354:
--------------------------------

bq. Hey Hoss, I think you mean StatsInfo should do the check you propose? At 
least, that's where I found I needed to start intercepting this.

Hmmm... i guess there's two code paths here that have to be considered?  I 
think i was looking at SimpleStats because that's where the individual 
{{stats.field}} values are parsed into the "localParams" variable -- so we 
definitely need to check for a type there, and then do the right thing as far 
as dealing with the NumericStatsValues in terms of methods like 
{{SimpleStats.getStatsFields()}} and/or {{SimpleStats.getFieldCacheStats()}}

But i think you're right about StatsInfo ... looks like we need to account for 
it there as well ... i'd need to look over this more closely to understand 
what's going on there and why....

bq. ...having a little trouble seeing how to go from ValueSource -> 
StatsValues. Can you provide a couple more pointers here? 

If you look at {{StatsValuesFactory.createStatsValues}} and the existing 
{{AbstractStatsValues}} you'll see that it maintains references to the 
SchemaField/FieldType of the associated field -- but the meat of the logic is 
in asking the FieldType for it's ValueSource to then accumulate values from.  
So what i had in mind was  refactoring "field" specific bits of 
{{AbstractStatsValues}} as needed so that a (new) subclass could be completely 
field agnostic, and just do the accumulation directly from a VlaueSource passed 
in (based on the FunctionQParser in most cases)

bq. I have all but the last line in your proposal implemented...

FYI: no need to "hold back" changes until they are "done" ... yonik's law of 
patches...

bq. A half-baked patch in Jira, with no documentation, no tests and no 
backwards compatibility is better than no patch at all.



> 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

Reply via email to