Order by an expression in Solr

后端 未结 3 619
半阙折子戏
半阙折子戏 2021-01-05 13:23

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 Categ

3条回答
  •  醉梦人生
    2021-01-05 13:32

    I've accepted hross's answer, but it's also possible to do something like this in Solr 1.3 and up, using:

    /select?q={!func}map(Category,20,20,1,0)&sort=score desc
    

    The cool thing is that you can still sort on other fields, so:

    &sort=score desc, name asc
    

提交回复
热议问题