Module: Chewie::Interface::Bool

Included in:
Chewie
Defined in:
lib/chewie/interface/bool.rb

Instance Method Summary collapse

Instance Method Details

#filter_by(attribute, with:, combine: [], format: nil) ⇒ Hash

Note:

See README#filtering-by-associations use case for :combine and :filter options

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

Parameters:

  • attribute (Symbol)

    Field you wish to search

  • with (Symbol)

    Specify the term-level query [term, terms, range]

  • combine (Array) (defaults to: [])

    Target additional filter values to be combined in the formatted output (optional)

  • format (Lambda) (defaults to: nil)

    Define custom output with :combine values at runtime (optional)

Returns:

  • (Hash)

    A valid bool query



12
13
14
15
16
17
18
19
20
21
22
# 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) ⇒ Hash

Note:

See README#filtering-by-associations use case for :combine and :filter options

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

Parameters:

  • attribute (Symbol)

    Field you wish to search

  • with (Symbol)

    Specify the term-level query [term, terms, range]

  • combine (Array) (defaults to: [])

    Target additional filter values to be combined in the formatted output (optional)

  • format (Lambda) (defaults to: nil)

    Define custom output with :combine values at runtime (optional)

Returns:

  • (Hash)

    A valid bool query



51
52
53
54
55
56
57
58
59
60
61
62
# 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) ⇒ Hash

Note:

See README#filtering-by-associations use case for :combine and :filter options

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

Parameters:

  • attribute (Symbol)

    Field you wish to search

  • with (Symbol)

    Specify the term-level query [term, terms, range]

  • combine (Array) (defaults to: [])

    Target additional filter values to be combined in the formatted output (optional)

  • format (Lambda) (defaults to: nil)

    Define custom output with :combine values at runtime (optional)

Returns:

  • (Hash)

    A valid bool query



38
39
40
41
42
43
44
45
46
47
48
# 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) ⇒ Hash

Note:

See README#filtering-by-associations use case for :combine and :filter options

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

Parameters:

  • attribute (Symbol)

    Field you wish to search

  • with (Symbol)

    Specify the term-level query [term, terms, range]

  • combine (Array) (defaults to: [])

    Target additional filter values to be combined in the formatted output (optional)

  • format (Lambda) (defaults to: nil)

    Define custom output with :combine values at runtime (optional)

Returns:

  • (Hash)

    A valid bool query



25
26
27
28
29
30
31
32
33
34
35
# 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