如何在Solr 9.0中显示搜索结果的单个文档得分?
如何在Solr 9.0中显示每个搜索结果的单独得分?
你当前使用的查询语句仅指定返回name字段:
http://localhost:8983/solr/techproducts/select?q=cat:electronics&fl=name
Solr的fl(字段列表)参数控制返回哪些字段,默认不会自动包含每个文档的匹配得分。要让每个搜索结果显示单独得分,只需在fl参数中添加score字段即可。
修改后的查询语句:
http://localhost:8983/solr/techproducts/select?q=cat:electronics&fl=name,score
修改后返回的结果示例:
"response": {
"numFound": 12,
"start": 0,
"maxScore": 0.5244061,
"numFoundExact": true,
"docs": [
{
"name": "Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133",
"score": 0.5244061
},
{
"name": "Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300",
"score": 0.4879028
},
{
"name": "Belkin Mobile Power Cord for iPod w/ Dock",
"score": 0.4512378
}
]
}
这样每个文档对象中就会包含对应的score字段,展示该结果与查询条件的匹配得分。
内容的提问来源于stack exchange,提问作者marlon
相关产品推荐
相关产品推荐

