Use the same index reader to create the weight and the scorers.

Otherwise there might be class cast exceptions because of incompatible TermState impls.


git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1663328 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2015-03-02 15:26:26 +00:00
parent e4f06aba2d
commit f3edb95218
1 changed files with 2 additions and 2 deletions

View File

@ -614,7 +614,7 @@ public class TestBooleanQuery extends LuceneTestCase {
q.add(new TermQuery(new Term("field", "c")), Occur.FILTER); q.add(new TermQuery(new Term("field", "c")), Occur.FILTER);
final Weight weight = searcher.createNormalizedWeight(q, random().nextBoolean()); final Weight weight = searcher.createNormalizedWeight(q, random().nextBoolean());
final Scorer scorer = weight.scorer(reader.leaves().get(0), null); final Scorer scorer = weight.scorer(searcher.getIndexReader().leaves().get(0), null);
assertTrue(scorer instanceof ConjunctionScorer); assertTrue(scorer instanceof ConjunctionScorer);
assertNotNull(scorer.asTwoPhaseIterator()); assertNotNull(scorer.asTwoPhaseIterator());
@ -676,7 +676,7 @@ public class TestBooleanQuery extends LuceneTestCase {
q.add(new TermQuery(new Term("field", "d")), Occur.SHOULD); q.add(new TermQuery(new Term("field", "d")), Occur.SHOULD);
final Weight weight = searcher.createNormalizedWeight(q, random().nextBoolean()); final Weight weight = searcher.createNormalizedWeight(q, random().nextBoolean());
final Scorer scorer = weight.scorer(reader.leaves().get(0), null); final Scorer scorer = weight.scorer(searcher.getIndexReader().leaves().get(0), null);
assertTrue(scorer instanceof BoostedScorer || scorer instanceof ExactPhraseScorer); assertTrue(scorer instanceof BoostedScorer || scorer instanceof ExactPhraseScorer);
assertNotNull(scorer.asTwoPhaseIterator()); assertNotNull(scorer.asTwoPhaseIterator());