class Arelastic::Queries::Bool

Attributes

filter[RW]
must[RW]
must_not[RW]
options[RW]
should[RW]

Public Class Methods

new(options) click to toggle source
# 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

Public Instance Methods

as_elastic() click to toggle source
# 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