You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Chetan Shah <ch...@gmail.com> on 2009/03/02 16:46:48 UTC

Sort Collection of ScoreDocs

Is there an existing Utility class which will sort a collection of ScoreDocs
? I have a result set (array of ScoreDocs) stored in JVM and want to sort
them by relevanceScore. I do not want to execute the query again. The stored
result set is sorted by another term and hence the need.

Would highly appreciate if you would please let me know how do I do so?

Thanks,

-Chetan
-- 
View this message in context: http://www.nabble.com/Sort-Collection-of-ScoreDocs-tp22290563p22290563.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

RE: Sort Collection of ScoreDocs

Posted by Chetan Shah <ch...@gmail.com>.
Perfect Thanks.

Was also looking at org.apache.lucene.search.ScoreDocComparator




Uwe Schindler wrote:
> 
> How about java.util.Arrays.sort() on the array using a simple
> Comparator<ScoreDoc> with a compare() that returns -Float.compare(a.score,
> b.score)? This is just about 7 lines of Java code.
> 
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
> 
>> -----Original Message-----
>> From: Chetan Shah [mailto:chetankrshah@gmail.com]
>> Sent: Monday, March 02, 2009 4:47 PM
>> To: java-user@lucene.apache.org
>> Subject: Sort Collection of ScoreDocs
>> 
>> 
>> Is there an existing Utility class which will sort a collection of
>> ScoreDocs
>> ? I have a result set (array of ScoreDocs) stored in JVM and want to sort
>> them by relevanceScore. I do not want to execute the query again. The
>> stored
>> result set is sorted by another term and hence the need.
>> 
>> Would highly appreciate if you would please let me know how do I do so?
>> 
>> Thanks,
>> 
>> -Chetan
>> --
>> View this message in context: http://www.nabble.com/Sort-Collection-of-
>> ScoreDocs-tp22290563p22290563.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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Sort-Collection-of-ScoreDocs-tp22290563p22291550.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


RE: Sort Collection of ScoreDocs

Posted by Uwe Schindler <uw...@thetaphi.de>.
How about java.util.Arrays.sort() on the array using a simple
Comparator<ScoreDoc> with a compare() that returns -Float.compare(a.score,
b.score)? This is just about 7 lines of Java code.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Chetan Shah [mailto:chetankrshah@gmail.com]
> Sent: Monday, March 02, 2009 4:47 PM
> To: java-user@lucene.apache.org
> Subject: Sort Collection of ScoreDocs
> 
> 
> Is there an existing Utility class which will sort a collection of
> ScoreDocs
> ? I have a result set (array of ScoreDocs) stored in JVM and want to sort
> them by relevanceScore. I do not want to execute the query again. The
> stored
> result set is sorted by another term and hence the need.
> 
> Would highly appreciate if you would please let me know how do I do so?
> 
> Thanks,
> 
> -Chetan
> --
> View this message in context: http://www.nabble.com/Sort-Collection-of-
> ScoreDocs-tp22290563p22290563.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