From ab5a62cf466af2b654ded4192de9e050b952aba7 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Wed, 28 Sep 2011 20:33:16 +0000 Subject: [PATCH] add a test that tests more than one document git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1177048 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/search/TestQueryWrapperFilter.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java b/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java index cf61e9ffcea..8225510c07c 100644 --- a/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java +++ b/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java @@ -18,12 +18,14 @@ package org.apache.lucene.search; */ import org.apache.lucene.document.Document; +import org.apache.lucene.document.StringField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.store.Directory; +import org.apache.lucene.util.English; import org.apache.lucene.util.LuceneTestCase; public class TestQueryWrapperFilter extends LuceneTestCase { @@ -80,4 +82,30 @@ public class TestQueryWrapperFilter extends LuceneTestCase { reader.close(); dir.close(); } + + public void testThousandDocuments() throws Exception { + Directory dir = newDirectory(); + RandomIndexWriter writer = new RandomIndexWriter(random, dir); + for (int i = 0; i < 1000; i++) { + Document doc = new Document(); + doc.add(newField("field", English.intToEnglish(i), StringField.TYPE_UNSTORED)); + writer.addDocument(doc); + } + + IndexReader reader = writer.getReader(); + writer.close(); + + IndexSearcher searcher = newSearcher(reader); + + for (int i = 0; i < 1000; i++) { + TermQuery termQuery = new TermQuery(new Term("field", English.intToEnglish(i))); + QueryWrapperFilter qwf = new QueryWrapperFilter(termQuery); + TopDocs td = searcher.search(new MatchAllDocsQuery(), qwf, 10); + assertEquals(1, td.totalHits); + } + + searcher.close(); + reader.close(); + dir.close(); + } }