Class: Solr::Query::Request::Sorting::Field

Inherits:
Object
  • Object
show all
Includes:
Support::SchemaHelper
Defined in:
lib/solr/query/request/sorting/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support::SchemaHelper

#solarize_field

Constructor Details

#initialize(name:, direction:) ⇒ Field

Returns a new instance of Field.



10
11
12
13
14
# File 'lib/solr/query/request/sorting/field.rb', line 10

def initialize(name:, direction:)
  @name = name
  @direction = direction
  freeze
end

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



8
9
10
# File 'lib/solr/query/request/sorting/field.rb', line 8

def direction
  @direction
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/solr/query/request/sorting/field.rb', line 8

def name
  @name
end

Instance Method Details

#solr_fieldObject



21
22
23
# File 'lib/solr/query/request/sorting/field.rb', line 21

def solr_field
  solarize_field(name)
end

#to_solr_sObject

sorting nulls last, not-nulls first



17
18
19
# File 'lib/solr/query/request/sorting/field.rb', line 17

def to_solr_s
  "exists(#{solr_field}) desc, #{solr_field} #{direction}"
end