SuU*_*bha 5 sorting solr relevance
我需要按相关性对 solr 结果进行排序。我使用以下代码进行排序:
fq={!tag=resourcetag}(post_type:resource AND (siec_database_item:no OR siec_database_item:"") )&showposts=10&solrsearch=1&paged=0&sortby=score desc
但它没有得到任何结果。我在网上搜索,但只收到了有关相关性排序的理论。我需要一些实际的解决方案。
仅供参考,显示一个示例,我只是使用 id 和 Score 字段fl
http://localhost:8983/solr/test/select?fl=id,score&indent=on&q=ipod&wt=json
Run Code Online (Sandbox Code Playgroud)
对于查询,q=ipod我们有 6 个从 solr 返回的文档,如下所示。您可以注意到文档是根据相关性得分值排序的。(降序顺序,默认)
response":{"numFound":6,"start":0,"maxScore":4.391201,"docs":[
{
"id":"IW-02",
"score":4.391201},
{
"id":"F8V7067-APL-KIT",
"score":4.1061177},
{
"id":"09",
"score":3.690675},
{
"id":"01",
"score":3.597126},
{
"id":"3007WFRD",
"score":3.1348155},
{
"id":"MA147LL/A",
"score":1.9562671}]
Run Code Online (Sandbox Code Playgroud)
如果您希望结果按升序排列,只需在 url 中添加排序参数&sort=score asc,结果就会改变。您也可以对其他字段进行相同的排序。(例如:排序=价格升序)。