Class: Sunspot::RandomField

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/field.rb

Overview

RandomField instances are used for random sorting.

Instance Method Summary collapse

Instance Method Details

#indexed_nameObject

Solr uses the dynamic field name as a seed for random, so we randomize the field name accordingly.

#XXX I think it’s bad to use a random number as a seed. Would it be better to pass in the current timestamp or some such thing?



153
154
155
# File 'lib/sunspot/field.rb', line 153

def indexed_name
  "random_#{rand(1<<16)}"
end

#multiple?Boolean

Never multiple, but this has to return false so Sunspot doesn’t barf when you try to order by it.

Returns:

  • (Boolean)


142
143
144
# File 'lib/sunspot/field.rb', line 142

def multiple?
  false
end