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);