TopDocsCollector.topDocs() does return the results sorted, by score. It basically returns a slice of a PriorityQueue. You can take a look at the source<http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TopDocsCollector.java>, it's one of the easier parts of the code.
On Wed, Mar 16, 2011 at 2:48 AM, Ryan Aylward <r...@glassdoor.com> wrote: > Does the TopDocsCollector sort the docs it returns? > > The java doc for... > > public final TopDocs topDocs(int start) > > states.... > > Returns the documents in the range [start .. pq.size()) that were collected > by this collector. Note that if start >= pq.size(), an empty TopDocs is > returned. > This method is convenient to call if the application always asks for the > last results, starting from the last 'page'. > > So it returns the proper results for a given page, but it is not clear that > it sorts the results for that page. > > I would have thought it does sort the results for the returned docs, but > I'm seeing some results that show that the results are not sorted. > > Thanks, > Ryan > > >