lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken McCracken <ken.mccrac...@gmail.com>
Subject lucene Scorers
Date Fri, 12 Nov 2004 19:48:04 GMT
Hi,

I am looking at the Similarity class overview, and wondering if I can
replace the SUM operator with a MAX operator, or any other operator
(across the terms in a query).

For example, if I search for "car OR automobile", a BooleanScorer is
used to add the values from each subexpression together.  In the
BooleanScorer from lucene_1_4_final, in the inner class Collector, we
have in the collect(...) method, the line

     bucket.score += score;			  // increment score

that I may want replace with a MAX operator such as 

     if (score > bucket.score) bucket.score = score;        // take the max

I may also want to keep track of both the max and the sum, by
extending the inner class Bucket.

Do you have any suggestions on how to implement such a change? 
Ideally, I would like to have the ability to define my choice of
scoring algorithm at search time (at run time), and use the Lucene SUM
scorer for some searches, and the MAX scorer for other searches.

Thanks for you help.

-Ken

PS.  The code I'm talking about falls in the follwoing area, for my
example search "car OR automobile".  If I walk the code during search,
I see that the BooleanScorer$Collector is created by the Weight that
was just created, in BooleanQuery$BooleanWeight.scorer(...), as it
adds the subscorers for each of the terms in the BooleanScorer.  When
that collector is asked to collect(...), its bucketTable is filled in.
 Since the collectors for each of the terms use the same bucketTable,
if the document already appears in the bucketTable, then it's score is
added to implement a SUM operator.

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


Mime
View raw message