【发布时间】:2019-10-11 22:12:17
【问题描述】:
我是 Solr 的初学者。可能有错误。对不起。 我正在使用版本 7.7.1。 假设有下一个文件:
{
"documents": [
{
"id": 1,
"category": [
"a",
"b"
],
"score":0.10 //lucene score
},
{
"id": 2,
"category": [
"b",
"c",
"d",
"e"
],
"score":0.20 //lucene score
},
{
"id": 3,
"category": [
"a",
"e"
],
"score":0.30 //lucene score
},
{
"id": 4,
"category": [
"d",
"e"
],
"score":0.40 //lucene score
},
{
"id": 5,
"category": [
"a",
"c"
],
"score":0.50 //lucene score
}
]
}
主要任务是下一个。我得到 3 个或更多不同的类别,我只需要一个文档,每个类别的得分最高。换句话说,我需要按类别字段对结果进行分组,每个组都必须按分数 desc 排序,并且每个组都必须限制为 1。
例如得到 a,b,c 类别的结果必须包含 3 个文档
document with id == 5 for a category
document with id == 2 for b category
document with id == 5 for c category
是否可以通过单个请求创建 solr 查询来获得这样的结果?
我尝试了接下来的方法,但它们没有帮助或效果不佳:
由于类别字段是集合,因此不考虑分组。
Faceting 仅返回结果数。我需要一份完整的文件。
可以对每个类别进行请求。但是一次可以有50个类别,我想在solr中发出50个请求会很耗时。
感谢和问候
【问题讨论】: