lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Multiple sort field
Date Wed, 18 Jul 2012 17:11:34 GMT
Lucene certainly supports multiple sort criteria, see
IndexSearcher.search, any one that takes a Sort
object. The Sort object can contain a list of fields where
any ties in the first N field(s) are decided by looking
at field N+1.

But, Ganesh, be a little careful about resolving by internal
Lucene doc ID. Not only do they change during merges, but
some policies re-order them. I'd put in an ordinal number
that was the insertion order.

Best
Erick

On Wed, Jul 18, 2012 at 8:34 AM, googoo <liuyt1@gmail.com> wrote:
> I don't think lucene will support multi sort.
> If you look into org.apache.lucene.search.TopScoreDocCollector you may get
> some feeling.
> It use max heap to sort the document, and the score is one time calculate,
> it it not first sort by time, then sort again by id.
>
> When lucene sort below documents:
> record_1  201207170101
> record_2  201207170101
> record_3  201207170102
> record_4  201207170102
>
> first get record_1, and it score is 201207170101, then record_1 on top of
> the heap
> tehn get record_2, and it score is 201207170101, then will put record_2
> after record_1
> then get record_3, and it score is 201207170102, this score > current top
> value 201207170101, then the max heap change to record_3, record_1, record_2
> last get record_3, and it score is 201207170102, is score = current top male
> 201207170102, , then the max heap change to record_3, record_4, record_1,
> record_2
>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Multiple-sort-field-tp3995502p3995699.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