Thinking Sphinx,复杂排序 - 如何将扩展排序与 expr 排序结合起来?
我想按表达式排序,然后按某个属性升序排序,然后按另一个属性升序排序。像这样的东西: :order => “(a <某个常量)desc,b asc,c asc”
。如何获得?
由于 <
,扩展排序无法工作。 Expr 由于逗号而失败。
我已经设法产生相当于 :order => 的排序“(a < 某个常量) desc, b desc”
与 :order => "(a < 某个常数)", :sort_mode => :expr, :sort_by => :b
,但我无法向该排序添加另一个属性 (c
),也无法将 b
的排序模式更改为 asc。
I want to sort by expression, then by some attribute ascending, then by another attribute ascending. Something like this: :order => "(a < some constant) desc, b asc, c asc"
. How to get it?
Extended sorting refuses to work because of <
. Expr fails because of commas.
I have managed to produce sorting equivalent to :order => "(a < some constant) desc, b desc"
with :order => "(a < some constant)", :sort_mode => :expr, :sort_by => :b
, but I can't add another attribute (c
) to that sorting nor change sorting mode for b
to asc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SetSelect 函数允许创建任意排序。我不确定它是否在thinking-sphinx中可用,因此可能需要修改这个gem。
SetSelect function allows for creating arbitrary sorts. I am not sure if it is available in thinking-sphinx, so modification of this gem may be necessary.