I am new in solr i want to sort parent document by child documents lowest price . Please see below mentioned sample data.
{
"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,
}
]
} }
And i want to result below mentioned format
{
"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,
}
]
}
}
I tried below mentioned link it's not worked for my issue.
how to sort parent documents by child attributes in solr
sort={!parent which=type:parent score=max v=’+type:child +{!func}price’} desc