/* Implemented as state.boost() * lengthNorm(numTerms), where numTerms is FieldInvertState.length() if setDiscountOverlaps() is false, else it's FieldInvertState.length() - FieldInvertState.numOverlap(). */ func (ds *DefaultSimilarity) lengthNorm(state *index.FieldInvertState) float32 { var numTerms int if ds.discountOverlaps { numTerms = state.Length() - state.NumOverlap() } else { numTerms = state.Length() } return state.Boost() * float32(1.0/math.Sqrt(float64(numTerms))) }
func (wrapper *PerFieldSimilarityWrapper) ComputeNorm(state *index.FieldInvertState) int64 { return wrapper.spi.Get(state.Name()).ComputeNorm(state) }