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 08:18:46 GMT

On Sep 17, 2005, at 7:00 PM, James Huang wrote:

> I use a custom collector:
>
[...]
>
> Then, use IndexSearcher.search(qry, collector);

So what happens if you get 10M results from a search?

> This seems to work. What I wish for is that sorting is
> done by the search engine itself, hoping for a better
> performance (and cleaner code).

And it can be done by Lucene itself...

> Previously, I have created a DistanceComparatorSource
> (similar to that in LIA-ch6); sorting by distance
> works but relevance is lost.

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});

     Erik

>
> -James
>
> --- Erik Hatcher <erik@ehatchersolutions.com> wrote:
>
>
>>
>> On Sep 17, 2005, at 4:10 PM, James Huang wrote:
>>
>>
>>> Hi,
>>>
>>> I can sort the search results by distance now.
>>>
>> But,
>>
>>> the relevance is lost.
>>>
>>> I like to have the results sorted by relevance +
>>> distance, i.e., relevance first; for results of
>>> similar relevance, order by distance. How to do
>>>
>> that?
>>
>> How are you currently sorting?   You can use
>> multiple sort fields
>> within a Sort.
>>
>>      Erik
>>
>>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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