Permalink
Browse files

Fix bug in explain for function_score queries.

The explain output for function_score queries with score_mode=max or
score_mode=min was incorrect, returning instead the value of the last
function.  This change fixes this.
  • Loading branch information...
rboulton authored and brwe committed Dec 10, 2013
1 parent 6c18931 commit 1037d071bfc2b6e535ec1f532681afdd837b2502
@@ -202,15 +202,15 @@ public Explanation explain(AtomicReaderContext context, int doc) throws IOExcept
factor = filterExplanations.get(0).getValue();
break;
case Max:
double maxFactor = Double.NEGATIVE_INFINITY;
factor = Double.NEGATIVE_INFINITY;
for (int i = 0; i < filterExplanations.size(); i++) {
factor = Math.max(filterExplanations.get(i).getValue(), maxFactor);
factor = Math.max(filterExplanations.get(i).getValue(), factor);
}
break;
case Min:
double minFactor = Double.POSITIVE_INFINITY;
factor = Double.POSITIVE_INFINITY;
for (int i = 0; i < filterExplanations.size(); i++) {
factor = Math.min(filterExplanations.get(i).getValue(), minFactor);
factor = Math.min(filterExplanations.get(i).getValue(), factor);
}
break;
case Multiply:

0 comments on commit 1037d07

Please sign in to comment.