LUCENE-5489: fix test bug

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1580181 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-03-22 08:18:22 +00:00
parent 9b9357c5e3
commit 4163f0aa59
1 changed files with 13 additions and 7 deletions

View File

@ -32,6 +32,15 @@ import org.apache.lucene.util.LuceneTestCase;
public class TestQueryRescorer extends LuceneTestCase {
private IndexSearcher getSearcher(IndexReader r) {
IndexSearcher searcher = newSearcher(r);
// We rely on more tokens = lower score:
searcher.setSimilarity(new DefaultSimilarity());
return searcher;
}
public void testBasic() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random(), dir);
@ -52,10 +61,7 @@ public class TestQueryRescorer extends LuceneTestCase {
BooleanQuery bq = new BooleanQuery();
bq.add(new TermQuery(new Term("field", "wizard")), Occur.SHOULD);
bq.add(new TermQuery(new Term("field", "oz")), Occur.SHOULD);
IndexSearcher searcher = newSearcher(r);
// We rely on more tokens = lower score:
searcher.setSimilarity(new DefaultSimilarity());
IndexSearcher searcher = getSearcher(r);
TopDocs hits = searcher.search(bq, 10);
assertEquals(2, hits.totalHits);
@ -111,7 +117,7 @@ public class TestQueryRescorer extends LuceneTestCase {
BooleanQuery bq = new BooleanQuery();
bq.add(new TermQuery(new Term("field", "wizard")), Occur.SHOULD);
bq.add(new TermQuery(new Term("field", "oz")), Occur.SHOULD);
IndexSearcher searcher = newSearcher(r);
IndexSearcher searcher = getSearcher(r);
TopDocs hits = searcher.search(bq, 10);
assertEquals(2, hits.totalHits);
@ -165,7 +171,7 @@ public class TestQueryRescorer extends LuceneTestCase {
BooleanQuery bq = new BooleanQuery();
bq.add(new TermQuery(new Term("field", "wizard")), Occur.SHOULD);
bq.add(new TermQuery(new Term("field", "oz")), Occur.SHOULD);
IndexSearcher searcher = newSearcher(r);
IndexSearcher searcher = getSearcher(r);
TopDocs hits = searcher.search(bq, 10);
assertEquals(2, hits.totalHits);
@ -243,7 +249,7 @@ public class TestQueryRescorer extends LuceneTestCase {
BooleanQuery bq = new BooleanQuery();
bq.add(new TermQuery(new Term("field", "wizard")), Occur.SHOULD);
bq.add(new TermQuery(new Term("field", "oz")), Occur.SHOULD);
IndexSearcher searcher = newSearcher(r);
IndexSearcher searcher = getSearcher(r);
TopDocs hits = searcher.search(bq, 10);
assertEquals(2, hits.totalHits);