lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
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);
  }

Mike

On Tue, Feb 16, 2010 at 2:07 PM, Raimon Bosch <raimon.bosch@gmail.com> 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
> http://lucene.apache.org/java/2_9_1/api/all/org/apache/lucene/search/TopFieldCollector.html
>
> --
> View this message in context: http://old.nabble.com/CompareBottom-in-FieldComparator-tp27613452p27613452.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message