Solr:如何指定字段相关性/权重

4
我目前正在使用Solr对大约10个字段的数据进行索引。当我执行搜索时,我希望某些字段的权重更高。有谁能帮我指点一下方向吗?
例如,对于像“超人”这样的术语在所有字段中进行搜索,应该在“标题”字段中返回结果,而不是在“描述”字段中。
我已经找到了如何使一个字段从查询中得分更高的文档,但我更喜欢在配置文件或类似文件中设置它。以下内容要求所有搜索都指定权重。是否可以在solr配置文件中指定此项?
q=title:superman^2 description:superman
3个回答

5

尝试使用带有ExtendedDisMax的qf,您的查询看起来会像这样:

q=superman

您的配置文件将如下所示:

<str name="qf">title^2 description</str>

您可以在这里获取一些工作示例


感谢您的帮助!我已成功配置了edismax解析器并应用了适当的权重 - 再次感谢您的帮助!! - Nathan Hall
我需要在Java程序中更改qf值,但是在SolrQuery对象中没有看到任何可用于此的方法,是否有不同的类可供使用? - cnu

3

The qf parameter introduces a list of fields, each of which is assigned a boost factor to increase or decrease that particular field's importance in the query. For example, the query below:

qf="fieldOne^2.3 fieldTwo fieldThree^0.4"

Assigns fieldOne a boost of 2.3, leaves fieldTwo with the default boost (because no boost factor is specified), and fieldThree a boost of 0.4. These boost factors make matches in fieldOne much more significant than matches in fieldTwo, which in turn are much more significant than matches in fieldThree."

来源: Apache Lucene

针对您的情况,qf="title^100 description" 可以解决问题 - 如果您正在图书馆使用Solr,我很乐意聊聊。


0

通过使用edismax,我们可以实现您所寻找的功能。

尝试通过更改字段在您的请求处理程序中添加这两个字段。 如果您不需要某个特定字段,可以完全删除它。

<str name="defType"> edismax </str>
<str name="qf"> YourField^50 YourAnotherField^30 YetAnotherField</str>

随着幂(^)的增加,该字段的优先级也越高。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接