为 SynonymFilterFactory 术语赋予权重

giving weight for SynonymFilterFactory terms

Solr 中有什么方法可以赋予同义词权重? (由 SynonymFilterFactory 生成)

较长版本的问题/一些背景:

我们想为 SynonymFilterFactory 注入的同义词 words/terms 赋予较小的权重。 所以精确匹配会更高 score.

第一个用例只是为所有同义词赋予一个静态权重 如果搜索时间通过同义词匹配,它将具有一定的(较低的) 重量比完全匹配。

在文档中找不到这个。

Solr 是否有办法为 SynonymFilterFactory 产生的项分配权重?

非常感谢任何指点。

PS。另一个用例是用特定的权重微调每个同义词 对于每个特定的同义词(即 synonyms="synonyms.txt" 将有 3 列而不是 2)。目前似乎不可能,所以也许只是静态的 上述所有同义词的权重都是可能的。

与 Lucene 的大多数情况一样,解决方案是使用多个字段 - 一个扩展了同义词的字段,一个不扩展同义词的字段。这样您就可以决定是否完全启用同义词搜索,或者您可以在具有不同权重的不同字段中对命中进行评分 - 您可以根据您的查询调整这些权重。在 Solr 中,您使用 copyField 将相同的内容索引到两个字段中,然后您可以在使用带有 field^5 field_with_synonyms 的 edismax 时调整权重,使没有同义词的命中率比有同义词的命中率高五倍。

如果您真的想在一个单一的字段中完成它,它将需要更加脆弱和自定义的设置,其中您can use payloads attached to each token to manually score each token differently, but this is a more advanced use case and won't fit neatly into all other functionality. It'll solve your PS use case, though. I'd also recommend checking out one of the presentations from Lucene/Solr Revolution关于用例有效载荷评分。

使用两个字段是最简单的方法,使用有效载荷是更灵活但也更高级的方法。

Returns the float value computed from the decoded payloads of the term specified.

return 值是使用解码有效负载的最小值、最大值或平均值计算得出的。可以使用特殊的第一个函数代替其他函数,short-circuit 术语枚举和 return 仅第一个术语的解码有效负载。

The field specified must have float or integer payload encoding capability (via DelimitedPayloadTokenFilter or NumericPayloadTokenFilter). If no payload is found for the term, the default value is returned.

payload(field_name,term): default value is 0.0, average function is used.

payload(field_name,term,default_value): default value can be a constant, field name, or another float returning function. average function used.

payload(field_name,term,default_value,function): function values can be min, max, average, or first.

与 DelimitedPayloadTokenFilter 一起使用的文件采用 token|payload 格式,允许您附加任何数值作为该令牌的“有效负载”。