lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Taylor <>
Subject Re: Problem modifying Similarity class to work with lucene 3.1.0
Date Tue, 03 May 2011 14:29:28 GMT
On 03/05/2011 15:06, Robert Muir wrote:
> On Tue, May 3, 2011 at 9:57 AM, Paul Taylor<>  wrote:
>> How can I convert this Similariity method to use 3.1 (currently using
>> 3.0.3), I understand I have to replace lengthNorm() wuth computerNorm() ,
>> but fieldlName is not a provided parameter in computerNorm() and
>> FieldInvertState does not contain the fieldname either.
> Hi, I think you made a mistake, it does take fieldname:
> org.apache.lucene.index.FieldInvertState)
Doh thanks, not having a good few days, trying to do to much at once.

I assume this would be the correct way to fix the code for 3.1.0

public float computeNorm(String field, FieldInvertState state) {

         //This will match both artist and label aliases and is 
applicable to both, didn't use the constant
         //ArtistIndexField.ALIAS because that would be confusing
         if (field.equals("alias")) {
             return state.getBoost() * 0.578f; //Same result as normal 
calc if field had three terms the most common scenario
             return super.computeNorm(field,state);


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message