new FileSystemDirectory(fs, new Path(shards[i].getDirectory()),
false, conf);
readers[i] = IndexReader.open(dir);
}
IndexReader reader = new MultiReader(readers);
IndexSearcher searcher = new IndexSearcher(reader);
Hits hits = searcher.search(new TermQuery(new Term("content", "apache")));
assertEquals(numRuns * numDocsPerRun, hits.length());
int[] counts = new int[numDocsPerRun];
for (int i = 0; i < hits.length(); i++) {
Document doc = hits.doc(i);
counts[Integer.parseInt(doc.get("id"))]++;
}
for (int i = 0; i < numDocsPerRun; i++) {
assertEquals(numRuns, counts[i]);
}
// max field length is 2, so "dot" is also indexed but not "org"
hits = searcher.search(new TermQuery(new Term("content", "dot")));
assertEquals(numRuns, hits.length());
hits = searcher.search(new TermQuery(new Term("content", "org")));
assertEquals(0, hits.length());
searcher.close();
reader.close();
// open and close an index writer with KeepOnlyLastCommitDeletionPolicy
// to remove earlier checkpoints
for (int i = 0; i < shards.length; i++) {
Directory dir =