LUCENE-6270: Fix test bug.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1661462 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2015-02-22 08:56:39 +00:00
parent 6c8dc4e115
commit bf83ae2a44
1 changed files with 6 additions and 1 deletions

View File

@ -69,7 +69,7 @@ public class TermsQueryTest extends LuceneTestCase {
doc.add(new StringField(term.field(), term.text(), Store.NO));
iw.addDocument(doc);
}
if (random().nextBoolean()) {
if (numTerms > 1 && random().nextBoolean()) {
iw.deleteDocuments(new TermQuery(allTerms.get(0)));
}
iw.commit();
@ -77,6 +77,11 @@ public class TermsQueryTest extends LuceneTestCase {
final IndexSearcher searcher = newSearcher(reader);
iw.close();
if (reader.numDocs() == 0) {
// may occasionally happen if all documents got the same term
continue;
}
for (int i = 0; i < 100; ++i) {
final float boost = random().nextFloat() * 10;
final int numQueryTerms = TestUtil.nextInt(random(), 1, 1 << TestUtil.nextInt(random(), 1, 8));