我是 solr 的新手,我想按价格最低的子文档对父文档进行排序。请参阅下面提到的示例数据。
{
"parentID": 1,
"children": {
"numFound": 2,
"start": 0,
"docs": [
{
"type": "child",
"parentID": 1,
"ID": "1",
"price": 189.7
},
{
"type": "child",
"parentID": 1,
"ID": "2",
"price": 933.1
}
]
} }, {
"parentID": 2,
"children": {
"numFound": 2,
"start": 0,
"docs": [
{
"type": "child",
"parentID": 2,
"ID": "1",
"price": 1180.0
},
{
"type": "child",
"parentID": 2,
"ID": "2",
"price": 238.0
}
]
} }, {
"parentID": 3,
"children": {
"numFound": 1,
"start": 0,
"docs": [
{
"type": "child",
"parentID": 3,
"ID": "1",
"price": 1442.81,
},
{
"type": "child",
"parentID": 3,
"ID": "2",
"price": 42.81,
}
]
} }, {
"parentID": 4,
"children": {
"numFound": 1,
"start": 0,
"docs": [
{
"type": "child",
"parentID": 4,
"ID": "1",
"price": 1140.8,
}
]
} }
我想得到下面提到的格式
{
"parentID": 3,
"children": {
"numFound": 1,
"start": 0,
"docs": [
{
"type": "child",
"parentID": 3,
"ID": "1",
"price": 1442.81,
},
{
"type": "child",
"parentID": 3,
"ID": "2",
"price": 42.81,
}
]
}
},
{
"parentID": 1,
"children": {
"numFound": 2,
"start": 0,
"docs": [
{
"type": "child",
"parentID": 1,
"ID": "1",
"price": 189.7
},
{
"type": "child",
"parentID": 1,
"ID": "2",
"price": 933.1
}
]
}
},
{
"parentID": 2,
"children": {
"numFound": 2,
"start": 0,
"docs": [
{
"type": "child",
"parentID": 2,
"ID": "2",
"price": 238.0
},
{
"type": "child",
"parentID": 2,
"ID": "1",
"price": 1180.0
}
]
}
},
{
"parentID": 4,
"children": {
"numFound": 1,
"start": 0,
"docs": [
{
"type": "child",
"parentID": 4,
"ID": "1",
"price": 1140.8,
}
]
}
}
我尝试了下面提到的链接,它不适用于我的问题。
sort={!parent which=type:parent score=max v='+type:child +{!func}price'} desc