cpoerschke commented on code in PR #1431: URL: https://github.com/apache/solr/pull/1431#discussion_r1126644129
########## 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: Wondering if `reRankWeight` at all or `reRankWeight` other than `1` makes sense for the `REPLACE` case? I guess it would allow scaling of the re-rank score. Taking the `scaling of the ... score` thought further ``` (originalWeight * score + reRankWeight * second) ``` might be another way to achieve 'replace' logic i.e. with `originalWeight==0` value. I have no strong views on this, just thinking out aloud. -- 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