You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 06:35:28