Search code examples
rubyruby-on-rails-5sphinxthinking-sphinx

sphinx search with specific ordre


I have list of company (what sphinx return), I want to sort them to (company with store first) without overriding the weight of fields.

I tried :

:order  => 'store DESC'

it's ok but the weight order has broken


Solution

  • If you want both the weight and the store to impact the ordering, you'll need to specify both - :order doesn't build upon existing values, it replaces them.

    :order => 'weight() DESC, store DESC'