lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <>
Subject Re: Sorting by relevance and a field
Date Fri, 13 Feb 2009 10:40:18 GMT

SortField.FIELD_SCORE lets you sort by relevance.

So then make a Sort that contains an array of two SortFields, eg:

   new Sort(new SortField[] {SortField.FIELD_SCORE, new  

and pass that when searching.  Lucene will then sort first by score,  
and when there are ties, second by myField (doing auto-detection to  
infer that field's type; if you know the type, pass that down when you  
create the SortField).


Yannick Caillaux wrote:

> Hi all,
> Lucene sorts by decreasing relevance by default.
> The SortField class is used for sorting by lucene field(s).
> First I must sort by relevance, then (for the results which have the  
> same relevance) I must sort by a lucene field (title for example).
> I don't know how to do that. Someone can help me?
> Thanks in advance
> Yannick
> -- 
> Ce message a été vérifié par MailScanner
> pour des virus ou des polluriels et rien de
> suspect n'a été trouvé.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message