Class: Daedal::Queries::MultiMatchQuery

Inherits:
Query
  • Object
show all
Defined in:
lib/daedal/queries/multi_match_query.rb

Instance Method Summary collapse

Methods inherited from Query

#to_json

Constructor Details

#initialize(options = {}) ⇒ MultiMatchQuery

Fields cannot be an empty array… should eventually refactor this kind of thing out of initialize



22
23
24
25
26
27
28
# File 'lib/daedal/queries/multi_match_query.rb', line 22

def initialize(options={})
  super options
  
  if fields.empty?
    raise "Must give at least one field to match on"
  end
end

Instance Method Details

#to_hashObject



30
31
32
33
34
35
36
37
# File 'lib/daedal/queries/multi_match_query.rb', line 30

def to_hash
  result = {multi_match: {query: query, fields: fields}}
  options = {minimum_should_match: minimum_should_match, cutoff_frequency: cutoff_frequency, type: type, analyzer: analyzer, boost: boost, fuzziness: fuzziness, operator: operator}
  
  result[:multi_match].merge!(options.select { |k,v| !v.nil? })
  
  result
end