List of usage examples for org.apache.lucene.index FieldInvertState getOffset
public int getOffset()
From source file:org.archive.jbs.lucene.WebSimilarity.java
License:Apache License
/** Normalize field by length. Called at index time. */ public float computeNorm(String fieldName, FieldInvertState state) { int numTokens = state.getLength(); if ("url".equals(fieldName)) { // URL: prefer short by using linear normalization return 1.0f / numTokens; } else if ("content".equals(fieldName)) { // Content: penalize short, by treating short as longer // TODO: Is creating a new FieldInvertState object good, or // should we modify the existing one? return super.computeNorm(fieldName, new FieldInvertState(state.getPosition(), Math.max(numTokens, MIN_CONTENT_LENGTH), state.getNumOverlap(), state.getOffset(), state.getBoost())); } else {//from ww w . j av a 2 s . co m // use default return super.computeNorm(fieldName, state); } }