Class: Elastic::Nodes::Nested
Constant Summary collapse
- SCORE_MODES =
[:avg, :sum, :min, :max, :none]
Instance Attribute Summary collapse
-
#child ⇒ Object
Returns the value of attribute child.
-
#path ⇒ Object
Returns the value of attribute path.
-
#score_mode ⇒ Object
Returns the value of attribute score_mode.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Methods included from Support::Traversable
Instance Attribute Details
#child ⇒ Object
Returns the value of attribute child.
12 13 14 |
# File 'lib/elastic/nodes/nested.rb', line 12 def child @child end |
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/elastic/nodes/nested.rb', line 12 def path @path end |
#score_mode ⇒ Object
Returns the value of attribute score_mode.
13 14 15 |
# File 'lib/elastic/nodes/nested.rb', line 13 def score_mode @score_mode end |
Class Method Details
.build(_path, _child) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/elastic/nodes/nested.rb', line 5 def self.build(_path, _child) new.tap do |node| node.path = _path node.child = _child end end |
Instance Method Details
#clone ⇒ Object
20 21 22 |
# File 'lib/elastic/nodes/nested.rb', line 20 def clone prepare_clone super, @child.clone end |
#render(_options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/elastic/nodes/nested.rb', line 40 def render( = {}) path = @path path = "#{_options[:query_path]}.#{path}" if .key? :query_path hash = { 'path' => path, 'query' => @child.render(.merge(query_path: path)) } hash['score_mode'] = @score_mode.to_s if @score_mode && @score_mode != :avg { "nested" => hash } end |
#simplify ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/elastic/nodes/nested.rb', line 29 def simplify new_child = @child.simplify if new_child.is_a? Nested prepare_clone(super, new_child.child).tap do |clone| clone.path = "#{clone.path}.#{new_child.path}" end else prepare_clone super, new_child end end |
#traverse(&_block) ⇒ Object
15 16 17 18 |
# File 'lib/elastic/nodes/nested.rb', line 15 def traverse(&_block) super @child.traverse(&_block) end |