如何提升包含字段上搜索短语的结果



我正在尝试将包含我的搜索短语的 Solr 搜索结果放在结果集的顶部(此处resourcename)。

我是Solr的初学者。我在网上搜索了一段时间,发现了一些相关的问题,比如:

使用函数查询在 Solr 中提高分数

具有提升函数的 SolrNet 查询

然后我开始尝试这样的查询:

https://localhost:8898/solr/collection1/select?defType=edismax&fl=resourcename&indent=on&q=resourcename:"test"*^200,%20content:"test"*^1&qf=resourcename^200%20content^2&rows=1000&wt=json
https://localhost:8898/solr/collection1/select?bf=if(exists(resourcename),100,1)&defType=edismax&fl=resourcename&indent=on&q=resourcename:"test"*^200,%20content:"test"*^1&rows=1000&wt=json
https://localhost:8898/solr/collection1/select?bf=if(exists(resourcename),100,1)&defType=edismax&fl=resourcename&indent=on&q=*:"test"*&rows=1000&wt=json
https://localhost:8898/solr/collection1/select?defType=edismax&fl=resourcename&indent=on&q=*:"test"*&qf=resourcename^200%20content^2&rows=1000&wt=json

但是,无论我尝试什么,我都会得到包含resourcename单词test的结果,而不仅仅是在结果的顶部。

知道我可能错过了什么或做错了什么吗?

有很多语法错误,我建议看看 solr wiki 上的查询解析器[1]。

作为建议,请始终查看已分析的查询并浏览搜索结果的调试功能。

为了获得您要求的行为,我将使用以下请求参数(引用自 wiki):

Q=福酒吧

qf=字段1^5 字段2^10

pf=字段1^50 字段2^20

defType=dismax

使用这些参数,Dismax 查询分析器将生成如下所示的查询:

(+(field1:foo^5 OR field2:foo^10) AND (field1:bar^5 OR field2:bar^10))

但它也会生成另一个仅用于提升结果的查询:

field1:"foo bar"^50 OR field2:"foo bar"^20

通过这种方式,您可以根据某些字段中的匹配项提升结果,并进行相关的提升,然后还可以提升出现在特定其他字段中的短语。

[1] https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser

最新更新