lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Keegan" <>
Subject Re: Lucene Ranking/scoring
Date Thu, 08 Mar 2007 14:27:17 GMT
I'm looking at how ReciprocalFloatFuncion and ReverseOrdFieldSource can be
used to rank documents by score and date ( contains
great stuff!). The values in the date field that are used for the
ValueSource are not actually used as 'floats', but rather their ordinal term
values from the FieldCache string index. This means that if the 'date' field
has 3000 unique string 'values' in the index, the values for 'x' in
ReciprocalFloatFuncion could be 0-2999. So if I want the most recent 'date'
to return a score of 1.0, one could set 'a' and 'b' in the function to

Do I have this right? I got bit confused at first because I assumed that the
actual field values were being used in the computation, but you really need
to know the unique term count in order to get the score 'right'.

By the way, as I try to get my head around the Score, Weight, and Boolean*
classes (and next(), skipTo()), I nominate these for discussion in Lucene In
Action II.


On 3/9/06, Yonik Seeley <> wrote:
> On 3/9/06, Yang Sun <> wrote:
> > Hi Yonik,
> > Thanks very much for your suggestion. The query boost works great for
> > keyword matching. But in my case, I need to rank the results by date and
> > title. For example, title:foo^2 abstract:foo^1.5 date:2004^3 will only
> boost
> > the document with date=2004. What I need is boosting the "distance" from
> the
> > specified date
> If all you need to do is boost more recent documents (and a single
> fixed boost will always work), then you can do that boosting at index
> time.
> > which means 2003 will have a better ranking than 2002,
> > 2002>2001, etc.
> > I implemented a customized ScoreDocComparator class which works fine for
> one
> > field. But I met some trouble when trying to combine other fields
> together.
> > I'm still looking at FunctionQuery. Don't know if I can figure out
> > something.
> FunctionQuery support is integrated into Solr (or currently hacked-in,
> as the case may be),  and can be useful for debugging and trying out
> query types even if you don't use it for your runtime.
> ReciprocalFloatFunction might meet your needs for increasing the score
> of more recent documents:
> The SolrQueryParser can make
> ReciprocalFloatFunction(new ReverseOrdFieldSource("my_date"),1,1000,1000)
> out of _val_:"recip(rord(my_date),1,1000,1000)"
> -Yonik
> Solr, The Open Source Lucene Search
> Server
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message