Class: Sunspot::Query::Sort::RandomSort
- Defined in:
- lib/sunspot/query/sort.rb
Overview
A RandomSort uses Solr’s random field functionality to sort results (usually) randomly.
Instance Method Summary collapse
-
#initialize(options = {:seed => rand(1<<16)}, direction = nil) ⇒ RandomSort
constructor
A new instance of RandomSort.
- #to_param ⇒ Object
Constructor Details
#initialize(options = {:seed => rand(1<<16)}, direction = nil) ⇒ RandomSort
Returns a new instance of RandomSort.
79 80 81 |
# File 'lib/sunspot/query/sort.rb', line 79 def initialize(={:seed => rand(1<<16)}, direction=nil) @seed, @direction = [:seed], (direction || :asc).to_sym end |
Instance Method Details
#to_param ⇒ Object
83 84 85 |
# File 'lib/sunspot/query/sort.rb', line 83 def to_param "random_#{@seed} #{direction_for_solr}" end |