Class: Arelastic::Queries::Bool

Inherits:
Query show all
Defined in:
lib/arelastic/queries/bool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Query

#negate, #nested

Methods inherited from Nodes::Node

#==, #convert_to_elastic, #read_option!

Methods included from Arities::Binary

#binary

Methods included from Arities::Polyadic

#polyadic

Methods included from Arities::Unary

#unary

Constructor Details

#initialize(options) ⇒ Bool

Returns a new instance of Bool.



5
6
7
8
9
10
11
# File 'lib/arelastic/queries/bool.rb', line 5

def initialize(options)
  @must     = read_option! options, 'must'
  @filter   = read_option! options, 'filter'
  @should   = read_option! options, 'should'
  @must_not = read_option! options, 'must_not'
  @options  = options
end

Instance Attribute Details

#filterObject

Returns the value of attribute filter.



4
5
6
# File 'lib/arelastic/queries/bool.rb', line 4

def filter
  @filter
end

#mustObject

Returns the value of attribute must.



4
5
6
# File 'lib/arelastic/queries/bool.rb', line 4

def must
  @must
end

#must_notObject

Returns the value of attribute must_not.



4
5
6
# File 'lib/arelastic/queries/bool.rb', line 4

def must_not
  @must_not
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/arelastic/queries/bool.rb', line 4

def options
  @options
end

#shouldObject

Returns the value of attribute should.



4
5
6
# File 'lib/arelastic/queries/bool.rb', line 4

def should
  @should
end

Instance Method Details

#as_elasticObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/arelastic/queries/bool.rb', line 13

def as_elastic
  searches = {}

  {
    'must'     => must,
    'filter'   => filter,
    'should'   => should,
    'must_not' => must_not
  }.each do |k, v|
    searches[k] = convert_to_elastic(v) if v
  end

  { 'bool' => searches.update(options) }
end