FAQ
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

Search Discussions

  • Israel Tsadok at Mar 16, 2011 at 6:21 am
    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 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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedMar 16, '11 at 12:47a
activeMar 16, '11 at 6:21a
posts2
users2
websitelucene.apache.org

2 users in discussion

Ryan Aylward: 1 post Israel Tsadok: 1 post

People

Translate

site design / logo © 2022 Grokbase