lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raimon Bosch <raimon.bo...@gmail.com>
Subject Re: CompareBottom in FieldComparator
Date Wed, 17 Feb 2010 11:28:33 GMT

Hi Michael,

I've seen that our main problem is that copy() method is always sending
documents in the same order (between two queries with same content in
different time). So it is a problem if we use compareBottom a lot because
the documents at the begining of the queue recieve more comparations than
the documents at the end of the queue. It works well with standard
ordenations, but not with pseudo-random ordenations.

Is there a way to do a shuffle to the docs to copy before starting
ordenation for each query? If not, the best way to work would be to have a
high numHits when we create the TopFieldCollectors to avoid the use of
CompareBottom.

Regards,
Raimon Bosch.


Michael McCandless-2 wrote:
> 
> 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
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/CompareBottom-in-FieldComparator-tp27613452p27622297.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


Mime
View raw message