Module: Chewie::Interface::FullText

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

Instance Method Summary collapse

Instance Method Details

#match(attribute, context: :query, clause: nil, options: {}) ⇒ Hash

Parameters:

Returns:

  • (Hash)

    A valid “must” query



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/chewie/interface/full_text.rb', line 11

def match(attribute, context: :query, clause: nil, options: {})
  handler = {
    query: :match,
    clause: clause,
    attribute: attribute,
    query_type: :full_text,
    options: options,
  }

  set_handler(context: context, handler: handler)
end

#multimatch(with: [], context: :query, clause: nil, options: {}) ⇒ Hash

Parameters:

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

    A collection of field symbols to match against

  • context (Symbol) (defaults to: :query)
  • clause (Symbol) (defaults to: nil)

    Specify a nested clause, usually context dependent (optional)

  • options (Hash) (defaults to: {})

    Options to augment search behavior

Returns:

  • (Hash)

    A valid “multi-match” query



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/chewie/interface/full_text.rb', line 30

def multimatch(with: [], context: :query, clause: nil, options: {})
  if context == :compound
    raise 'Please include a :clause value for compound queries.'
  end

  handler = {
    query: :multimatch,
    clause: clause,
    with: with,
    query_type: :full_text,
    options: options,
  }

  set_handler(context: context, handler: handler)
end