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
|