Class: Boolminot::Clauses::Nested

Inherits:
Base
  • Object
show all
Defined in:
lib/boolminot/clauses/nested.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base::ClassMethods

#predicate_factory

Methods included from Base::InstanceMethods

#satisfied_by?, #to_elasticsearch_negated, #to_raw_bool

Constructor Details

#initialize(path, clause, opts) ⇒ Nested

Returns a new instance of Nested.



6
7
8
9
10
# File 'lib/boolminot/clauses/nested.rb', line 6

def initialize(path, clause, opts)
  @path   = path
  @clause = clause
  @opts   = opts
end

Instance Attribute Details

#clauseObject (readonly)

Returns the value of attribute clause.



4
5
6
# File 'lib/boolminot/clauses/nested.rb', line 4

def clause
  @clause
end

#optsObject (readonly)

Returns the value of attribute opts.



4
5
6
# File 'lib/boolminot/clauses/nested.rb', line 4

def opts
  @opts
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/boolminot/clauses/nested.rb', line 4

def path
  @path
end

Instance Method Details

#to_elasticsearch(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/boolminot/clauses/nested.rb', line 12

def to_elasticsearch(options = {})
  default_options = {
    context: :filter
  }
  options = default_options.merge(options)

  context = options.fetch(:context)
  inner   = clause.to_elasticsearch(options)

  { type => { path: path }.merge(context => inner).merge(opts) }
end