From fa935cf6ac7a76042e5f5c6188719ab6a2cde429 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Thu, 11 Jan 2018 20:08:14 +0100 Subject: [PATCH] SOLR-11846: Force BM25Similarity on TestFieldCacheSort.testFieldScoreReverse. This test expects scores to increase with freq, which not all similarities guarantee. --- .../test/org/apache/solr/uninverting/TestFieldCacheSort.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSort.java b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSort.java index 9588e67dff9..2c0862fe4f4 100644 --- a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSort.java +++ b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSort.java @@ -50,6 +50,7 @@ import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortField; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; +import org.apache.lucene.search.similarities.BM25Similarity; import org.apache.lucene.store.Directory; import org.apache.solr.uninverting.UninvertingReader.Type; import org.apache.lucene.util.LuceneTestCase; @@ -434,6 +435,8 @@ public class TestFieldCacheSort extends LuceneTestCase { writer.close(); IndexSearcher searcher = newSearcher(ir); + // this test expects the freq to make doc 1 scores greater than doc 0 + searcher.setSimilarity(new BM25Similarity()); Sort sort = new Sort(new SortField(null, SortField.Type.SCORE, true)); TopDocs actual = searcher.search(new TermQuery(new Term("value", "foo")), 10, sort);