[solr ] solr自定义Similarity问题
薄荷红茶September
2016-03-22
自定义了一个similarity,仿照classicsimilarity写的,代码如下
public class CustomSimilarity extends TFIDFSimilarity{ @Override public float coord(int overlap, int maxOverlap) { return 1/ (float)maxOverlap; } @Override public float decodeNormValue(long arg0) { return 1; } @Override public long encodeNormValue(float arg0) { return 1; } @Override public float idf(long docFreq, long numDocs) { return 1; } @Override public float lengthNorm(FieldInvertState state) { final int numTerms; if (discountOverlaps) numTerms = state.getLength() - state.getNumOverlap(); else numTerms = state.getLength(); return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms))); } @Override public float queryNorm(float sumOfSquaredWeights) { return 1; } @Override public float scorePayload(int doc, int start, int end, BytesRef payload) { return 1; } @Override public float sloppyFreq(int distance) { return 1; } @Override public float tf(float freq) { return 1; } protected boolean discountOverlaps = true; public void setDiscountOverlaps(boolean v) { discountOverlaps = v; } /** * Returns true if overlap tokens are discounted from the document's length. * @see #setDiscountOverlaps */ public boolean getDiscountOverlaps() { return discountOverlaps; } @Override public String toString() { return "CustomSimilarity"; } } 但是lengthNorm()方法一直没有被调用(无论怎么改都不影响得分),请问各位大神什么原因呀? |
相关讨论
相关资源推荐
- [solr] solr Similarity:切换不同相似度计算方法
- 【solr】自定义扩展similarity class开发&使用
- 【大数据开发运维解决方案】通过降低term在文档出现频率的权重案例教你Solr/Elasticsearch如何自定义Similarity
- solr5.5(5)——Similarity简单介绍
- springboot实现solr分数自定义
- solr 相关度评分,自定义评分
- solr自定义评分器
- elasticsearch 自定义similarity 插件开发
- solr入门之自定义排序之构建自己的权重计算方法及相应的排序字段
- Solr为不同的fieldType配置Similarity