private void doIndexAndSearchTestWithRepeats(File file,
Class<? extends LineParser> lineParserClass, int numAdds, String storedField) throws Exception {
IndexReader reader = null;
IndexSearcher searcher = null;
PerfRunData runData = null;
try {
Properties props = new Properties();
// LineDocSource specific settings.
props.setProperty("docs.file", file.getAbsolutePath());
if (lineParserClass != null) {
props.setProperty("line.parser", lineParserClass.getName());
}
// Indexing configuration.
props.setProperty("analyzer", WhitespaceAnalyzer.class.getName());
props.setProperty("content.source", LineDocSource.class.getName());
props.setProperty("directory", "RAMDirectory");
props.setProperty("doc.stored", "true");
props.setProperty("doc.index.props", "true");
// Create PerfRunData
Config config = new Config(props);
runData = new PerfRunData(config);
TaskSequence tasks = new TaskSequence(runData, "testBzip2", null, false);
tasks.addTask(new CreateIndexTask(runData));
for (int i=0; i<numAdds; i++) {
tasks.addTask(new AddDocTask(runData));
}
tasks.addTask(new CloseIndexTask(runData));
try {
tasks.doLogic();
} finally {
tasks.close();
}
reader = DirectoryReader.open(runData.getDirectory());
searcher = newSearcher(reader);
TopDocs td = searcher.search(new TermQuery(new Term("body", "body")), 10);
assertEquals(numAdds, td.totalHits);
assertNotNull(td.scoreDocs[0]);