Module: Arelastic::Nodes::Nested

Included in:
Filters::Nested, Queries::Nested
Defined in:
lib/arelastic/nodes/nested.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
7
8
# File 'lib/arelastic/nodes/nested.rb', line 4

def self.included(klass)
  klass.class_eval do
    attr_accessor :path, :expr
  end
end

Instance Method Details

#as_elasticObject



19
20
21
22
23
24
25
26
# File 'lib/arelastic/nodes/nested.rb', line 19

def as_elastic
  params = {
    'path'          => path,
    search_context  => convert_to_elastic(expr)
  }

  { 'nested' => params }
end

#initialize(path, expr) ⇒ Object



10
11
12
13
# File 'lib/arelastic/nodes/nested.rb', line 10

def initialize(path, expr)
  @path = path
  @expr = expr
end

#search_contextObject



15
16
17
# File 'lib/arelastic/nodes/nested.rb', line 15

def search_context
  is_a?(Arelastic::Filters::Filter) ? 'filter' : 'query'
end