module Chewie::Interface::Bool

Public Instance Methods

filter_by(attribute, with:, combine: [], format: nil) click to toggle source

www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

@param attribute [Symbol] Field you wish to search @param with [Symbol] Specify the term-level query [term, terms, range] @param combine [Array] Target additional filter values to be combined in the formatted output (optional) @param format [Lambda] Define custom output with :combine values at runtime (optional) @return [Hash] A valid bool query @note See README#filtering-by-associations use case for :combine and :filter options

# File lib/chewie/interface/bool.rb, line 12
def filter_by(attribute, with:, combine: [], format: nil)
  handler = {
    query: :filter,
    attribute: attribute, 
    with: with,
    combine: combine, 
    format: format,
    query_type: :bool,
  }
  set_handler(context: :bool, handler: handler)
end
must_include(attribute, with:, combine: [], format: nil) click to toggle source

(see filter_by)

# File lib/chewie/interface/bool.rb, line 51
def must_include(attribute, with:, combine: [], format: nil)
  handler = {
    query: :must,
    attribute: attribute, 
    with: with,
    combine: combine, 
    format: format,
    query_type: :bool,
  }

  set_handler(context: :bool, handler: handler)
end
must_not_include(attribute, with:, combine: [], format: nil) click to toggle source

(see filter_by)

# File lib/chewie/interface/bool.rb, line 38
def must_not_include(attribute, with:, combine: [], format: nil)
  handler = {
    query: :must_not,
    attribute: attribute, 
    with: with,
    combine: combine, 
    format: format,
    query_type: :bool,
  }
  set_handler(context: :bool, handler: handler)
end
should_include(attribute, with:, combine: [], format: nil) click to toggle source

(see filter_by)

# File lib/chewie/interface/bool.rb, line 25
def should_include(attribute, with:, combine: [], format: nil)
  handler = {
    query: :should,
    attribute: attribute, 
    with: with,
    combine: combine, 
    format: format,
    query_type: :bool,
  }
  set_handler(context: :bool, handler: handler)
end