sonatype-lift[bot] commented on code in PR #1692: URL: https://github.com/apache/solr/pull/1692#discussion_r1227251140
########## solr/core/src/java/org/apache/solr/search/ReRankWeight.java: ########## @@ -24,24 +24,65 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.Rescorer; import org.apache.lucene.search.Weight; +import org.apache.solr.request.SolrRequestInfo; /** A {@code Weight} used by reranking queries. */ public class ReRankWeight extends FilterWeight { private final IndexSearcher searcher; private final Rescorer reRankQueryRescorer; + private final ReRankScaler reRankScaler; + private final ReRankOperator reRankOperator; public ReRankWeight( - Query mainQuery, Rescorer reRankQueryRescorer, IndexSearcher searcher, Weight mainWeight) + Query mainQuery, + Rescorer reRankQueryRescorer, + IndexSearcher searcher, + Weight mainWeight, + ReRankScaler reRankScaler, + ReRankOperator reRankOperator) throws IOException { super(mainQuery, mainWeight); this.searcher = searcher; this.reRankQueryRescorer = reRankQueryRescorer; + this.reRankScaler = reRankScaler; + this.reRankOperator = reRankOperator; } @Override public Explanation explain(LeafReaderContext context, int doc) throws IOException { final Explanation mainExplain = in.explain(context, doc); - return reRankQueryRescorer.explain(searcher, mainExplain, context.docBase + doc); + final Explanation reRankExplain = + reRankQueryRescorer.explain(searcher, mainExplain, context.docBase + doc); + if (reRankScaler.getReRankScalerExplain().reRankScale()) { + float reRankScore = reRankExplain.getValue().floatValue(); + float mainScore = mainExplain.getValue().floatValue(); + if (reRankScore > 0.0f) { + float scaledMainScore = + SolrRequestInfo.getRequestInfo().getResponseBuilder().mainScaleExplain.scale(mainScore); Review Comment: <picture><img alt="16% of developers fix this issue" src="https://lift.sonatype.com/api/commentimage/fixrate/16/display.svg"></picture> <b>*NULL_DEREFERENCE:</b>* object returned by `getRequestInfo()` could be null and is dereferenced at line 62. --- <details><summary>ℹ️ Expand to see all <b>@sonatype-lift</b> commands</summary> You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings. | **Command** | **Usage** | | ------------- | ------------- | | `@sonatype-lift ignore` | Leave out the above finding from this PR | | `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR | | `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file | **Note:** When talking to LiftBot, you need to **refresh** the page to see its response. <sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org