BTW, HitQueue performs this comparison:
  protected final boolean lessThan(Object a, Object b) {
    ScoreDoc hitA = (ScoreDoc)a;
    ScoreDoc hitB = (ScoreDoc)b;
    if (hitA.score == hitB.score)
      return hitA.doc > hitB.doc;
    else
      return hitA.score < hitB.score;
  }
As you can see, the default sorting when using TopDocCollector is by score,
then by doc. So we kind of already made the choice for applications :-)

On Dec 8, 2007 8:55 AM, Chris Hostetter <[EMAIL PROTECTED]> wrote:

>
> : In general I would agree that people may want different implementations
> for
> : compare(), but I hardly see that's the case for ScoreDoc. After all, you
> can
> : either compare it by score or by doc (at least now). I believe that
> since
> : most people use the TopDocsHitCollector, they prefer the
> compare-by-score
> : approach ...
>
> sure, but that's not all your suggested compareTo does ... it first
> compares by score and then does a secondary comparison by docId.
> some people might want docs added "more recently" to sort first instead,
> some might want docid left out of hte comparison all together.
>
> This is where Comparators are more useful then compareTo methods.  We can
> add *lots* of different static inner Comparator classes to ScoreDoc, but
> if we add any compareTo method it could wind up burning someone down the
> road.
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Regards,

Shai Erera

Reply via email to