Lucene fieldNorm相似度计算和查询时间值之间的差异
我试图理解Lucene fieldNorm相似度计算和查询时间值之间的差异,lucene,indexing,metrics,Lucene,Indexing,Metrics,我试图理解fieldNorm是如何计算(在索引时)并在查询时使用(显然是重新计算)的 在所有的例子中,我都在使用StandardAnalyzer,没有停止词 在索引内容时使用DefaultSimilarity的computeNorm方法,我注意到它会返回两个特定文档: 文档A为0.5(其字段中有4个标记) 文档B的0.70710677(其字段中有2个令牌) 它通过使用以下公式来实现: state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)
fieldNorm
是如何计算(在索引时)并在查询时使用(显然是重新计算)的
在所有的例子中,我都在使用StandardAnalyzer,没有停止词
在索引内容时使用DefaultSimilarity
的computeNorm
方法,我注意到它会返回两个特定文档:
- 文档A为0.5(其字段中有4个标记)
- 文档B的0.70710677(其字段中有2个令牌)
state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
其中boost总是1
之后,当我查询这些文档时,我会在查询解释中看到
用于文档A0.5=fieldNorm(field=titre,doc=0)
用于文档B0.625=fieldNorm(field=titre,doc=1)
public float computeNorm(String pField, FieldInvertState state) {
norm = (float) (state.getBoost() + (1.0d / Math.sqrt(state.getLength())));
return norm;
}
在索引时,我现在得到:
- 1.5对于文档A(其字段中有4个标记)
- 1.7071068用于文档B(其字段中有2个令牌)
用于文档A1.5=fieldNorm(field=titre,doc=0)
用于文档B1.5=fieldNorm(field=titre,doc=1)
- 为什么相似性的computeNorm方法报告的索引时间字段规范与查询解释报告的索引时间字段规范不同
- 为什么,对于在索引时获得的两个不同的fieldNorm值(通过相似度计算),我在查询时得到相同的fieldNorm值