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 15:14:27 GMT

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

>
>
> --- Erik Hatcher <erik@ehatchersolutions.com> wrote:
>
>
>>
>> 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
>>
>>
>
> Then this is not what I want -- if I put FIELD_SCORE
> first, it'll rarely work because FIELD_SCORE's seldom
> are the same, practically leaving distance sorting out
> of the picture.
>
> What I want is a "compound" score, i.e., to adjust the
> score based on the distance, like this:
>
>   score *= 1.0 - distance/200.0;
>
> This formula seems to work well for my situation. Is
> there a way to modify the score during search?

Sounds like you want a new type of Query subclass that weight each  
document by a given distance.  Though I'm curious why just sorting by  
distance isn't sufficient for your situation.  Could you describe a  
bit more about what you're doing?

     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