In SQL you can order by an expression like:
SELECT * FROM a
ORDER BY CASE WHEN a.Category = 20 THEN 1 ELSE 0 DESC
so records who have Category = 20 are on top.
Is this possible in Solr?
Solr doesn't have an if/then (at least not until 4.0), but it does have a map function and the ability to use function queries in your sort. You can probably use something like this in your sort to achieve what you're after:
?q=*&sort=map(category,20,20,case,0),score desc
(untested)
Here is a thread that talks about using map for an if statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With