Home

小鱼驿站

02 Apr 2014

Ordering null values last in thinking-sphinx

Sometimes , you want to order the records by some columns that should not be nil. that is if the ordered columns values is nil the record should list the last .

###How to deal with it by think-sphinx? ###

Step 1: Add column nil index

has "example IS NULL", :as => :example_nil, :type => :boolean

Step 2: Order by example_nil

sphinx_options[:order] = "example_nil  ASC, xxx"

References:

  1. https://github.com/pat/thinking-sphinx/issues/737

Til next time,
small_fish__ at 15:12

scribble