【问题标题】:How is lucene boosting affected by lengthNorm similaritylucene boosting如何受lengthNorm相似性的影响
【发布时间】:2015-07-25 07:01:18
【问题描述】:

我有两个文档包含:

doc_1one two three four five Bingo

doc_2Bingo 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


    【解决方案1】:

    lengthNorm()DefaultSimilarity 中的default implementationstate.getBoost() * lengthNorm(numTerms)

    在您的实施中,您没有考虑到提升。为了让你的提升很重要,你可以让你的实现返回state.getBoost()

    【讨论】:

      猜你喜欢
      • 2018-02-21
      • 1970-01-01
      • 2011-10-05
      • 2013-06-28
      • 1970-01-01
      • 2013-08-21
      • 1970-01-01
      • 1970-01-01
      • 2010-11-10
      相关资源
      最近更新 更多