【发布时间】:2015-07-25 07:01:18
【问题描述】:
我有两个文档包含:
doc_1:one two three four five Bingo
doc_2:Bingo one two three four five
我在两个字段中分别编制索引,其中一个字段包含前 5 个术语,第二个包含最后一个术语。
TextField start_field = new TextField("start_words", content.substring(0, index), Field.Store.NO);
TextField end_field = new TextField("end_words", content.substring(index,content.length()-1, Field.Store.NO);
// index is index value of 5th ' '
为了更好地查看提升效果,我实现了以下相似性:
DefaultSimilarity customSimilarity = new DefaultSimilarity() {
@Override
public float lengthNorm(FieldInvertState state) {
return 1; // So length of each field would not matter
}
};
在不应用任何提升的情况下,搜索 Bingo 会导致两个文档具有相同的分数(如预期和预期的那样)。
但是,当对其中一个字段 (start_field.setBoost(5)) 应用提升时,两个分数保持相同,尽管 doc_2 的包含Bingo 的字段被提升了。
如果我删除 customSimilarity,提升将按预期工作。
为什么boosting 会被lengthNorm 停止,我怎样才能在给定的覆盖相似度下使提升工作?
【问题讨论】:
标签: java lucene similarity solr-boost