You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Peter Keegan <pe...@gmail.com> on 2007/03/08 15:27:17 UTC

Re: Lucene Ranking/scoring

I'm looking at how ReciprocalFloatFuncion and ReverseOrdFieldSource can be
used to rank documents by score and date (solr.search.function 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
2999.

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.

Peter

On 3/9/06, Yonik Seeley <ys...@gmail.com> wrote:
>
> On 3/9/06, Yang Sun <ys...@ist.psu.edu> 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:
>
> http://incubator.apache.org/solr/docs/api/org/apache/solr/search/function/ReciprocalFloatFunction.html
>
> The SolrQueryParser can make
> ReciprocalFloatFunction(new ReverseOrdFieldSource("my_date"),1,1000,1000)
> out of _val_:"recip(rord(my_date),1,1000,1000)"
>
> -Yonik
> http://incubator.apache.org/solr Solr, The Open Source Lucene Search
> Server
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Lucene Ranking/scoring

Posted by Chris Hostetter <ho...@fucit.org>.
: 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'.

you can use the actual values in FunctionQueries, except that:
  1) dates aren't numeric values that lend themselves well to functions
  2) the ReverseOrdinalValueSource comes in handy when you want the docs
with the highest value (ie: most recent date) to be "special" (ie: to plug
into your reciprical function and get the max value.

i suppose you could write a ValueSource that finds the max value of a
field and then a ValueSource that normalizes all the values of one
valuesource against the value(s) of another value source ... but no one
has done that yet (and it still wouldn't have a lot of meaning for dates)


-Hoss


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