On 03/05/2011 15:06, Robert Muir wrote:
On Tue, May 3, 2011 at 9:57 AM, Paul Taylor<paul_t...@fastmail.fm>  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:

http://lucene.apache.org/java/3_1_0/api/core/org/apache/lucene/search/Similarity.html#computeNorm(java.lang.String,
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
        }
        else
        {
            return super.computeNorm(field,state);
        }
    }


Paul

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

Reply via email to