当具有相同名称的多个字段具有不同的提升时会发生什么?

What Happens When Multiple Fields with the Same Name have Different Boosts?

Boost is by-Field in Lucene,然后在索引中设置。您可以添加多个名称 属性 设置为相同值的字段,然后系统会在这些字段中搜索该文档,就像您刚刚将这些术语的并集添加到该字段名称下的该文档中一样。

var field1 = new Field("Text", "aquaculture");
var field2 = new Field("Text", "fish");
field1.setBoost(1.0f);
field2.setBoost(2.0f);
var doc = new Document();
doc.AddField(field1);
doc.AddField(field2);

但是您可以在执行此操作时将提升设置为多个值 - 如果您这样做,会发生什么情况?每个字段中的术语是否设置为单独的提升级别,或者是否使用一个共享的提升级别?如果有,是后进先入还是随机?

(上面的代码是伪代码,只是为了说明将字段添加到单个 Doc 以帮助编码人员可视化它,我意识到在实际的 Lucene 中执行上述操作的实际代码有点不同 API)

对于当前版本的Lucene,这个问题已经不相关了。在字段上设置提升在 6.5 中已弃用,并且在 7.0 中不再受支持。见 LUCENE-6819 for discussion. The replacement, per the migration guide:

...index-time scoring factors should be indexed in a doc value field and combined with the score at query time using FunctionScoreQuery for instance.


在以前的版本中,如果将多个提升添加到同一字段,它们将相乘。这由 FieldInvertState 指定,这是传递给相似度的信息,相似度执行将该数据转换为存储在索引中的内容。

This is the cumulative product of document boost and field boost for all field instances sharing the same field name.