如何提高字段中包含搜索短语的结果
How to boost results that contain the search phrase on a field
我正在尝试将包含我的搜索短语 的 Solr 搜索结果放在结果集顶部的特定字段(此处为 resourcename
)。
我是 Solr 的初学者。我在网上搜索了很长时间,发现了一些相关问题,例如:
Use function query for boosting score in Solr
SolrNet queries with boost functions
然后我开始尝试使用如下查询:
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=foo bar
qf=field1^5 field2^10
pf=field1^50 field2^20
defType=dismax
With these parameters, the Dismax Query Parser generates a query that looks something like this:
(+(field1:foo^5 OR field2:foo^10) AND (field1:bar^5 OR field2:bar^10))
But it also generates another query that will only be used for boosting results:
field1:"foo bar"^50 OR field2:"foo bar"^20
通过这种方式,您可以根据某些字段中的匹配项提升结果,使用相关提升,然后提升出现在特定其他字段中的短语。
[1] https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser
我正在尝试将包含我的搜索短语 的 Solr 搜索结果放在结果集顶部的特定字段(此处为 resourcename
)。
我是 Solr 的初学者。我在网上搜索了很长时间,发现了一些相关问题,例如:
Use function query for boosting score in Solr
SolrNet queries with boost functions
然后我开始尝试使用如下查询:
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=foo bar
qf=field1^5 field2^10
pf=field1^50 field2^20
defType=dismax
With these parameters, the Dismax Query Parser generates a query that looks something like this:
(+(field1:foo^5 OR field2:foo^10) AND (field1:bar^5 OR field2:bar^10))
But it also generates another query that will only be used for boosting results:
field1:"foo bar"^50 OR field2:"foo bar"^20
通过这种方式,您可以根据某些字段中的匹配项提升结果,使用相关提升,然后提升出现在特定其他字段中的短语。
[1] https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser