Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

Multiple sort field

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


emailgane at yahoo

Jul 17, 2012, 3:53 AM

Post #1 of 5 (167 views)
Permalink
Multiple sort field

Hello all,

I have more than one record having same time stamp. When i sort by date time in decending order, the set of records which have same time stamp are displayed in the order of insertion. Basically it is displayed with asscending order of docid. But i want the reverse of that.

Consider the below set of records.
record_1 201207170101
record_2 201207170101
record_3 201207170102
record_4 201207170102

After search, it displays the results in below order
record_3 201207170102
record_4 201207170102
record_1 201207170101
record_2 201207170101

But i want, sort on date time and again sort on docid in reverse order.
record_4 201207170102
record_3 201207170102
record_2 201207170101
record_1 201207170101

Is it good to use multiple sort fields? Using sort on docid will consume any memory? Is there any other way out to acheive this.

Regards
Ganesh

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


emailgane at yahoo

Jul 17, 2012, 10:34 PM

Post #2 of 5 (162 views)
Permalink
Re: Multiple sort field [In reply to]

Any thoughts on this?

Regards
Ganesh

----- Original Message -----
From: "Ganesh" <emailgane [at] yahoo>
To: <java-user [at] lucene>
Sent: Tuesday, July 17, 2012 4:23 PM
Subject: [Bulk] Multiple sort field


Hello all,

I have more than one record having same time stamp. When i sort by date time in decending order, the set of records which have same time stamp are displayed in the order of insertion. Basically it is displayed with asscending order of docid. But i want the reverse of that.

Consider the below set of records.
record_1 201207170101
record_2 201207170101
record_3 201207170102
record_4 201207170102

After search, it displays the results in below order
record_3 201207170102
record_4 201207170102
record_1 201207170101
record_2 201207170101

But i want, sort on date time and again sort on docid in reverse order.
record_4 201207170102
record_3 201207170102
record_2 201207170101
record_1 201207170101

Is it good to use multiple sort fields? Using sort on docid will consume any memory? Is there any other way out to acheive this.

Regards
Ganesh

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


ian.lea at gmail

Jul 18, 2012, 1:34 AM

Post #3 of 5 (158 views)
Permalink
Re: Multiple sort field [In reply to]

> Any thoughts on this?

Patience ...

> Is it good to use multiple sort fields?

Absolutely, if that's what you need. On the other hand, if you don't
need it then it's a bad idea.

> Using sort on docid will consume any memory?

Don't know. Certainly won't use less than not sorting this way.

> Is there any other way out to acheive this.

If you could get a full timestamp you could index it as a NumericField
and sort on that. Or you could add some value to the existing
timestamp to make each one unique. Probably other ways too but that's
all I can think of right now.


--
Ian.


On Wed, Jul 18, 2012 at 6:34 AM, Ganesh <emailgane [at] yahoo> wrote:
> Any thoughts on this?
>
> Regards
> Ganesh
>
> ----- Original Message -----
> From: "Ganesh" <emailgane [at] yahoo>
> To: <java-user [at] lucene>
> Sent: Tuesday, July 17, 2012 4:23 PM
> Subject: [Bulk] Multiple sort field
>
>
> Hello all,
>
> I have more than one record having same time stamp. When i sort by date time in decending order, the set of records which have same time stamp are displayed in the order of insertion. Basically it is displayed with asscending order of docid. But i want the reverse of that.
>
> Consider the below set of records.
> record_1 201207170101
> record_2 201207170101
> record_3 201207170102
> record_4 201207170102
>
> After search, it displays the results in below order
> record_3 201207170102
> record_4 201207170102
> record_1 201207170101
> record_2 201207170101
>
> But i want, sort on date time and again sort on docid in reverse order.
> record_4 201207170102
> record_3 201207170102
> record_2 201207170101
> record_1 201207170101
>
> Is it good to use multiple sort fields? Using sort on docid will consume any memory? Is there any other way out to acheive this.
>
> Regards
> Ganesh
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


liuyt1 at gmail

Jul 18, 2012, 5:34 AM

Post #4 of 5 (159 views)
Permalink
Re: Multiple sort field [In reply to]

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 [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


erickerickson at gmail

Jul 18, 2012, 10:11 AM

Post #5 of 5 (156 views)
Permalink
Re: Multiple sort field [In reply to]

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 [at] gmail> 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 [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.