Reputation: 149
Please see my sample solr document below.
{
"title": "Apple"
},
{
"title": "Banana",
"popularity": 2
},
{
"title": "Mango",
"popularity": 3
},
{
"title": "Lemon",
"popularity": 1
}
By default the query is "title":* so all those solr document will return as result, sorted by title ascending order. It will look like this
Apple
Banana
Lemon
Mango
Now, what I want is to add another sorting which a bit tricky at least for me to implement :(. I want to sort it by title ascending and by popularity descending order which only involves the popularity that has a value of 3 and 2. The result should be like this
Mango
Banana
Apple
Lemon
The question is what would be the query?
Thanks
Upvotes: 0
Views: 38
Reputation: 75257
You can sort it as follows:
sort=map(popularity,2,3, popularity,0) desc, title asc
Upvotes: 1