[
https://issues.apache.org/jira/browse/SOLR-5524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13837319#comment-13837319
]
Trey Grainger commented on SOLR-5524:
-------------------------------------
I just debugged the code and uncovered the problem. There is a Map (called
context) that is passed through to each value source to store intermediate
state, and both the query and scale functions are passing the ValueSource for
the query function in as the KEY to this Map (as opposed to using some
composite key that makes sense in the current context). Essentially, these
lines are overwriting each other:
Inside ScaleFloatFunction: context.put(this.source, scaleInfo); //this.source
refers to the QueryValueSource, and the scaleInfo refers to a ScaleInfo object
Inside QueryValueSource: context.put(this, w); //this refers to the same
QueryValueSource from above, and the w refers to a Weight object
As such, when the ScaleFloatFunction later goes to read the ScaleInfo from the
context Map, it unexpectedly pulls the Weight object out instead and thus the
invalid case exception occurs. The NoOp multiplication works because it puts
an "different" ValueSource between the query and the ScaleFloatFunction such
that this.source (in ScaleFloatFunction) != this (in QueryValueSource).
> Exception when using Query Function inside Scale Function
> ---------------------------------------------------------
>
> Key: SOLR-5524
> URL: https://issues.apache.org/jira/browse/SOLR-5524
> Project: Solr
> Issue Type: Bug
> Affects Versions: 4.6
> Reporter: Trey Grainger
> Priority: Minor
> Fix For: 4.7
>
>
> If you try to use the query function inside the scale function, it throws the
> following exception:
> org.apache.lucene.search.BooleanQuery$BooleanWeight cannot be cast to
> org.apache.lucene.queries.function.valuesource.ScaleFloatFunction$ScaleInfo
> Here is an example request that invokes this:
> http://localhost:8983/solr/collection1/select?q=*:*&fl=scale(query($x),0,5)&x=hello)
--
This message was sent by Atlassian JIRA
(v6.1#6144)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]