dsmiley commented on code in PR #5119:
URL: https://github.com/apache/solr/pull/5119#discussion_r4476822044
##########
solr/core/src/java/org/apache/solr/handler/component/combine/ReciprocalRankFusion.java:
##########
@@ -127,26 +187,37 @@ public SimpleOrderedMap<Explanation> getExplanations(
List<ShardDoc> combinedQueriesDocs,
SolrParams solrParams) {
int kVal = solrParams.getInt(CombinerParams.COMBINER_RRF_K, this.k);
+ float[] weights = new float[queryKeys.length];
+ for (int i = 0; i < queryKeys.length; i++) {
+ weights[i] = getWeight(solrParams, queryKeys[i]);
+ }
SimpleOrderedMap<Explanation> docIdsExplanations = new
SimpleOrderedMap<>();
- Map<String, Integer[]> docIdToRanks = getRanks(queriesDocMap.values(),
combinedQueriesDocs);
+ Map<String, Integer[]> docIdToRanks = getRanks(queryKeys, queriesDocMap,
combinedQueriesDocs);
for (ShardDoc shardDoc : combinedQueriesDocs) {
String docId = shardDoc.id.toString();
Integer[] rankPerQuery = docIdToRanks.get(docId);
Explanation fullDocIdExplanation =
Explanation.match(
- shardDoc.score, getReciprocalRankFusionExplain(queryKeys,
rankPerQuery, kVal));
+ shardDoc.score,
+ getReciprocalRankFusionExplain(queryKeys, rankPerQuery, kVal,
weights));
docIdsExplanations.add(docId, fullDocIdExplanation);
}
return docIdsExplanations;
}
private String getReciprocalRankFusionExplain(
- String[] queryKeys, Integer[] rankPerQuery, int kVal) {
+ String[] queryKeys, Integer[] rankPerQuery, int kVal, float[] weights) {
StringBuilder reciprocalRankFusionExplain = new StringBuilder();
StringJoiner scoreComponents = new StringJoiner(" + ");
- for (Integer rank : rankPerQuery) {
+ for (int i = 0; i < queryKeys.length; i++) {
+ Integer rank = rankPerQuery[i];
if (rank != null) {
- scoreComponents.add("1/(" + kVal + "+" + rank + ")");
+ float weight = weights[i];
+ if (weight == CombinerParams.DEFAULT_COMBINER_RRF_WEIGHT) {
+ scoreComponents.add("1/(" + kVal + "+" + rank + ")");
+ } else {
Review Comment:
Why add this check; wouldn't the result look about the same without this
condition?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]