lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <>
Subject Re: CompareBottom in FieldComparator
Date Tue, 16 Feb 2010 22:28:25 GMT
The API is definitely confusing.

setBottom is called by Lucene to notify your FieldComparator which
slot holds the "weakest" entry.  You  can at that point cache that
entry (eg IntComparator stores the bottom int value at that point),
or, simply store that bottom slot in an instance variable.

Then, compareBottom is just like compare except compareBottom uses the
bottom slot instead of slot1.

So the simplest and correct thing to do in your comparator is
something like this (note: not tested!):

  int bottomSlot;

  public void setBottom(int slot) {
    bottomSlot = slot;
  public int compareBottom(int slot) {
    return compare(bottomSlot, slot);


On Tue, Feb 16, 2010 at 2:07 PM, Raimon Bosch <> wrote:
> Hi,
> Which is the exactly objective of compareBottom and setBottom functions. I
> am using a higher numHits to create TopScoreDocCollectors and
> TopFieldCollectors because I don't understand properly this function.
> I think that is a filter to send less documents to sort in comparators, but
> I don't get a way to maximize this amount of documents without forcing
> numHits. If we use a simple comparation the sorter is always sorting our
> most relevant document, so maybe we need a pseudo-random function? We are
> interested in sort a big amount of documents.
> Thanks in advance,
> Raimon Bosch.
> PD: See
> --
> View this message in context:
> Sent from the Lucene - Java Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message