0

我正在尝试将包含我的搜索短语的 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

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

有什么想法我可能会错过或做错吗?

4

1 回答 1

2

有很多语法错误,我建议查看 solr wiki for query parsers[1]。

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

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

q=foo 酒吧

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

pf=field1^50 field2^20

defType=dismax

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

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

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

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

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

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

于 2017-05-11T15:57:27.897 回答