Skip to content

Commit 3585673

Browse files
committed
address comments
1 parent f40f328 commit 3585673

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

core/src/main/java/org/elasticsearch/common/lucene/search/function/FiltersFunctionScoreQuery.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import java.io.IOException;
3838
import java.util.ArrayList;
3939
import java.util.Arrays;
40+
import java.util.Collection;
41+
import java.util.Collections;
4042
import java.util.List;
4143
import java.util.Locale;
4244
import java.util.Objects;
@@ -238,7 +240,7 @@ public Explanation explain(LeafReaderContext context, int doc) throws IOExceptio
238240
} else {
239241
// it is a little weird to add a match although no function matches but that is the way function_score behaves right now
240242
factorExplanation = Explanation.match(1.0f,
241-
"No function matched", new ArrayList<>());
243+
"No function matched", Collections.emptyList());
242244
}
243245
expl = combineFunction.explain(expl, factorExplanation, maxBoost);
244246
if (minScore != null && minScore > expl.getValue()) {

core/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -733,22 +733,22 @@ public void testExplanationAndScoreEqualsEvenIfNoFunctionMatches() throws IOExce
733733
CombineFunction combineFunction = randomFrom(new
734734
CombineFunction[]{CombineFunction.SUM, CombineFunction.AVG, CombineFunction.MIN, CombineFunction.MAX,
735735
CombineFunction.MULTIPLY, CombineFunction.REPLACE});
736-
736+
737737
// check for document that has no macthing function
738738
FiltersFunctionScoreQuery query = new FiltersFunctionScoreQuery(new TermQuery(new Term(FIELD, "out")), scoreMode,
739739
new FilterFunction[]{new FilterFunction(new TermQuery(new Term("_uid", "2")), new WeightFactorFunction(10))},
740740
Float.MAX_VALUE, Float.NEGATIVE_INFINITY, combineFunction);
741741
TopDocs searchResult = localSearcher.search(query, 1);
742-
Explanation exp1 = localSearcher.explain(query, searchResult.scoreDocs[0].doc);
743-
assertThat(searchResult.scoreDocs[0].score, equalTo(exp1.getValue()));
742+
Explanation explanation = localSearcher.explain(query, searchResult.scoreDocs[0].doc);
743+
assertThat(searchResult.scoreDocs[0].score, equalTo(explanation.getValue()));
744744

745745
// check for document that has a matching function
746746
query = new FiltersFunctionScoreQuery(new TermQuery(new Term(FIELD, "out")), scoreMode,
747747
new FilterFunction[]{new FilterFunction(new TermQuery(new Term("_uid", "1")), new WeightFactorFunction(10))},
748748
Float.MAX_VALUE, Float.NEGATIVE_INFINITY, combineFunction);
749749
searchResult = localSearcher.search(query, 1);
750-
exp1 = localSearcher.explain(query, searchResult.scoreDocs[0].doc);
751-
assertThat(searchResult.scoreDocs[0].score, equalTo(exp1.getValue()));
750+
explanation = localSearcher.explain(query, searchResult.scoreDocs[0].doc);
751+
assertThat(searchResult.scoreDocs[0].score, equalTo(explanation.getValue()));
752752
}
753753

754754
private static class DummyScoreFunction extends ScoreFunction {

0 commit comments

Comments
 (0)