class Tire::Search::MatchQuery

Public Class Methods

add(query, field, value, options={}) click to toggle source
# File lib/tire/search/queries/match.rb, line 26
def self.add(query, field, value, options={})
  unless query.value[:bool]
    original_value = query.value.dup
    query.value = { :bool => {} }
    (query.value[:bool][:must] ||= []) << original_value
  end
  query.value[:bool][:must] << MatchQuery.new(field, value, options).to_hash
end
new(field, value, options={}) click to toggle source
# File lib/tire/search/queries/match.rb, line 16
def initialize(field, value, options={})
  query_options = { :query => value }.merge(options)

  if field.is_a?(Array)
    @value = { :multi_match => query_options.merge( :fields => field ) }
  else
    @value = { :match => { field => query_options } }
  end
end

Public Instance Methods

to_hash() click to toggle source
# File lib/tire/search/queries/match.rb, line 35
def to_hash
  @value
end