better explanation calc with the change to factor in custom filters score

This commit is contained in:
Shay Banon 2012-01-05 00:09:40 +02:00
parent e5f2ce0fd6
commit df4a3bfd37

View File

@ -165,7 +165,7 @@ public class FiltersFunctionScoreQuery extends Query {
if (docSet.get(doc)) { if (docSet.get(doc)) {
filterFunction.function.setNextReader(reader); filterFunction.function.setNextReader(reader);
Explanation functionExplanation = filterFunction.function.explainFactor(doc); Explanation functionExplanation = filterFunction.function.explainFactor(doc);
float sc = getValue() * functionExplanation.getValue(); float sc = getValue() * subQueryExpl.getValue() * functionExplanation.getValue();
Explanation res = new ComplexExplanation(true, sc, "custom score, product of:"); Explanation res = new ComplexExplanation(true, sc, "custom score, product of:");
res.addDetail(new Explanation(1.0f, "match filter: " + filterFunction.filter.toString())); res.addDetail(new Explanation(1.0f, "match filter: " + filterFunction.filter.toString()));
res.addDetail(functionExplanation); res.addDetail(functionExplanation);
@ -185,13 +185,13 @@ public class FiltersFunctionScoreQuery extends Query {
if (docSet.get(doc)) { if (docSet.get(doc)) {
filterFunction.function.setNextReader(reader); filterFunction.function.setNextReader(reader);
Explanation functionExplanation = filterFunction.function.explainFactor(doc); Explanation functionExplanation = filterFunction.function.explainFactor(doc);
float sc = functionExplanation.getValue(); float factor = functionExplanation.getValue();
count++; count++;
total += sc; total += factor;
multiply *= sc; multiply *= factor;
max = Math.max(sc, max); max = Math.max(factor, max);
min = Math.min(sc, min); min = Math.min(factor, min);
Explanation res = new ComplexExplanation(true, sc, "custom score, product of:"); Explanation res = new ComplexExplanation(true, factor, "custom score, product of:");
res.addDetail(new Explanation(1.0f, "match filter: " + filterFunction.filter.toString())); res.addDetail(new Explanation(1.0f, "match filter: " + filterFunction.filter.toString()));
res.addDetail(functionExplanation); res.addDetail(functionExplanation);
res.addDetail(new Explanation(getValue(), "queryBoost")); res.addDetail(new Explanation(getValue(), "queryBoost"));
@ -199,25 +199,26 @@ public class FiltersFunctionScoreQuery extends Query {
} }
} }
if (count > 0) { if (count > 0) {
float sc = 0; float factor = 0;
switch (scoreMode) { switch (scoreMode) {
case Avg: case Avg:
sc = total / count; factor = total / count;
break; break;
case Max: case Max:
sc = max; factor = max;
break; break;
case Min: case Min:
sc = min; factor = min;
break; break;
case Total: case Total:
sc = total; factor = total;
break; break;
case Multiply: case Multiply:
sc = multiply; factor = multiply;
break; break;
} }
sc *= getValue();
float sc = factor * subQueryExpl.getValue() * getValue();
Explanation res = new ComplexExplanation(true, sc, "custom score, score mode [" + scoreMode.toString().toLowerCase() + "]"); Explanation res = new ComplexExplanation(true, sc, "custom score, score mode [" + scoreMode.toString().toLowerCase() + "]");
res.addDetail(subQueryExpl); res.addDetail(subQueryExpl);
for (Explanation explanation : filtersExplanations) { for (Explanation explanation : filtersExplanations) {