lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
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  
SortField(myField)})

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).

Mike

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: 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