gpt4 book ai didi

solr - 在 Solr 查询时忽略 tf/idf

转载 作者:行者123 更新时间:2023-12-04 23:25:25 29 4
gpt4 key购买 nike

我正在尝试根据字段值提升特定文档。它通常可以正常工作,但某些文档即使具有较小的 boost 值也会返回更高的分数。

使用 debugQuery=on 调试查询后请求参数我注意到 idf函数为特定文档返回更高的分数,这会影响整体分数。

有没有办法在查询时忽略 tf/idf 评分?

最佳答案

您需要创建一个自定义 Similarity它覆盖了 tf 和 idf 方法,并使用它代替 DefaultSimilarity。

就像是:

class CustomSimilarity extends DefaultSimilarity {

@Override
public float tf(float freq) {
return 1.0;
}

@Override
public float tf(int freq) {
return 1.0;
}

@Override
// Note the signature of this method may now take longs:
// public float idf(long docFreq, long numDocs)
public float idf(int docFreq, int numDocs) {
return 1.0;
}
}

将其设置为在您的 schema.xml 中使用该相似性:
<similarity class="myorg.mypackage.CustomSimilarity"/>

关于solr - 在 Solr 查询时忽略 tf/idf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13825170/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com