Document doc3 = new Document();
doc3.add(new TextField(text, "Foo3", Store.YES));
m_indexWriter.addDocument(doc3);
m_indexWriter.commit();
DirectoryReader reader = DirectoryReader.open(m_indexWriter, true);
IndexSearcher searcher = new IndexSearcher(reader);
TopScoreDocCollector docCollector = TopScoreDocCollector.create(100, true);
QueryParser queryParser = new QueryParser(Version.LUCENE_43, "text", new StandardAnalyzer(
Version.LUCENE_43));
Query query = queryParser.parse("Foo*");
searcher.search(query, docCollector);
TopDocs docs = docCollector.topDocs();
ScoreDoc[] scoreDocs = docs.scoreDocs;
assertEquals("should be doc 0", 0, scoreDocs[0].doc);
assertEquals("should be doc 1", 1, scoreDocs[1].doc);
assertEquals("should be doc 2", 2, scoreDocs[2].doc);
reader.close();
}