1 year ago
#374017
Pedro D
How to sort children documents on Solr
I'm trying to model a "parent" "children" relationship on Solr but I'm struggling to find a way to get the children documents ordered in some way. The basic query is:
q={!parent filters=$childquery which=document_type:product}
childquery=document_type:sku
fq=category:2
fl=*,[child childFilter=$childquery limit=-1]
and the result is similar to the following (I've cut attributes to be short). I would like the "skus" to be shown ordered by the field "rank" but I can't figure out how to set properly the "sort" parameter. I've tried sort=childfield(rank) but I get only the parents ordered.
Any help will be appreciated.
{
"id":"0RB2140",
"document_type":"product",
"category":"2",
"skus":[
{
"id":"0RB2140 901 54",
"document_type":"sku",
"rank":4
},
{
"id":"0RB2140 901 58",
"document_type":"sku",
"rank": 1
},
{
"id":"0RB2140 901 60",
"document_type":"sku",
"rank": 5
}
]
}
solr
solrcloud
solr8
0 Answers
Your Answer