lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Huang <metapr...@yahoo.com>
Subject Re: Sort by relevance+distance
Date Sun, 18 Sep 2005 15:10:00 GMT


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

Thanks,

-James

---------------------------------------------------------------------
> To unsubscribe, e-mail:
> java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail:
> java-user-help@lucene.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
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


Mime
View raw message