Class: Elastic::Nodes::Sort

Inherits:
Base
  • Object
show all
Includes:
Concerns::Sortable
Defined in:
lib/elastic/nodes/sort.rb

Constant Summary

Constants included from Concerns::Sortable

Concerns::Sortable::MODES, Concerns::Sortable::ORDER

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Sortable

#add_sort, #reset_sorts, #sorts

Methods inherited from Base

#==

Methods included from Support::Traversable

#pick_nodes

Instance Attribute Details

#childObject

Returns the value of attribute child.



5
6
7
# File 'lib/elastic/nodes/sort.rb', line 5

def child
  @child
end

Instance Method Details

#add_score_sort(order: :desc) ⇒ Object



7
8
9
# File 'lib/elastic/nodes/sort.rb', line 7

def add_score_sort(order: :desc)
  add_sort('_score', order: order)
end

#cloneObject



11
12
13
# File 'lib/elastic/nodes/sort.rb', line 11

def clone
  prepare_clone(super, child.try(:clone))
end

#handle_result(_raw, _formatter) ⇒ Object



29
30
31
# File 'lib/elastic/nodes/sort.rb', line 29

def handle_result(_raw, _formatter)
  @child.handle_result(_raw, _formatter)
end

#render(_options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/elastic/nodes/sort.rb', line 23

def render(_options = {})
  hash = child.render(_options)
  hash['sort'] = render_sorts
  hash
end

#simplifyObject



15
16
17
18
19
20
21
# File 'lib/elastic/nodes/sort.rb', line 15

def simplify
  if registered_sorts.empty?
    child.try(:simplify)
  else
    prepare_clone(super, child.try(:simplify))
  end
end

#traverse(&_block) ⇒ Object



33
34
35
36
# File 'lib/elastic/nodes/sort.rb', line 33

def traverse(&_block)
  super
  @child.traverse(&_block)
end