andywebb1975 commented on code in PR #1431:
URL: https://github.com/apache/solr/pull/1431#discussion_r1129845797


##########
solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java:
##########
@@ -68,29 +71,51 @@ public Query parse() throws SyntaxError {
       Query reRankQuery = reRankParser.parse();
 
       int reRankDocs = localParams.getInt(RERANK_DOCS, RERANK_DOCS_DEFAULT);
-      reRankDocs = Math.max(1, reRankDocs); //
+      reRankDocs = Math.max(1, reRankDocs);
 
       double reRankWeight = localParams.getDouble(RERANK_WEIGHT, 
RERANK_WEIGHT_DEFAULT);
 
-      return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight);
+      ReRankOperator reRankOperator =
+          ReRankOperator.get(localParams.get(RERANK_OPERATOR, 
RERANK_OPERATOR_DEFAULT));
+
+      return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight, 
reRankOperator);
     }
   }
 
   private static final class ReRankQueryRescorer extends QueryRescorer {
 
-    final double reRankWeight;
+    final BiFloatFunction scoreCombiner;
+
+    @FunctionalInterface
+    interface BiFloatFunction {
+      float func(float a, float b);
+    }
 
-    public ReRankQueryRescorer(Query reRankQuery, double reRankWeight) {
+    public ReRankQueryRescorer(
+        Query reRankQuery, double reRankWeight, ReRankOperator reRankOperator) 
{
       super(reRankQuery);
-      this.reRankWeight = reRankWeight;
+      switch (reRankOperator) {
+        case ADD:
+          scoreCombiner = (score, second) -> (float) (score + reRankWeight * 
second);
+          break;
+        case MULTIPLY:
+          scoreCombiner = (score, second) -> (float) (score * reRankWeight * 
second);
+          break;
+        case REPLACE:
+          scoreCombiner = (score, second) -> (float) (reRankWeight * second);

Review Comment:
   Just tried a negative `reRankWeight`, and saw no surprises: it leads to 
negative final scores, with more negative scores pushing items down the result 
set.



-- 
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

Reply via email to