lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Sort by relevance+distance
Date Sun, 18 Sep 2005 14:56:19 GMT

On Sep 18, 2005, at 10:24 AM, James Huang wrote:

> --- Erik Hatcher <erik@ehatchersolutions.com> wrote:
>
>
>> Get back to using your DistanceComparatorSource, and
>> couple that with
>> a SortField.FIELD_SCORE, like this:
>>
>> Sort sort = new Sort(new SortField[] {new
>> SortField("location",
>>          new DistanceComparatorSource(<whatever args
>> you need>)),
>> SortField.FIELD_SCORE});
>>
>
> Thanks!
>
> Does the order of thest two fields matter? I mean,
> with your code, would distance take precedence over
> relevance? Anyway, I'll try it out and play with
> ordering and such.

Yes, order matters - they sort in the order specified.  Subsequent  
SortField's in the list are only used when prior ones are  
equivalent.  In other words, when the distance is equal between two  
documents, then they are sorted by score.

     Erik


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