Module: Sunspot::Query::Sort

Defined in:
lib/sunspot/query/sort.rb

Overview

The classes in this module implement query components that build sort parameters for Solr. As well as regular sort on fields, there are several “special” sorts that allow ordering for metrics calculated during the search.

Defined Under Namespace

Classes: Abstract, DistanceSort, FieldSort, RandomSort, ScoreSort

Constant Summary collapse

DIRECTIONS =

:nodoc: all

{
  :asc => 'asc',
  :ascending => 'asc',
  :desc => 'desc',
  :descending => 'desc'
}

Class Method Summary collapse

Class Method Details

.special(name) ⇒ Object

Certain field names are “special”, referring to specific non-field sorts, which are generally by other metrics associated with hits.

XXX I’m not entirely convinced it’s a good idea to prevent anyone from ever sorting by a field named ‘score’, etc.



25
26
27
28
29
30
# File 'lib/sunspot/query/sort.rb', line 25

def special(name)
  special_class_name = "#{Util.camel_case(name.to_s)}Sort"
  if const_defined?(special_class_name) && special_class_name != 'FieldSort'
    const_get(special_class_name)
  end
end