Class: Tire::Search::MatchQuery
- Inherits:
-
Object
- Object
- Tire::Search::MatchQuery
- Defined in:
- lib/tire/search/queries/match.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(field, value, options = {}) ⇒ MatchQuery
constructor
A new instance of MatchQuery.
- #to_hash ⇒ Object
Constructor Details
#initialize(field, value, options = {}) ⇒ MatchQuery
Returns a new instance of MatchQuery.
16 17 18 19 20 21 22 23 24 |
# File 'lib/tire/search/queries/match.rb', line 16 def initialize(field, value, ={}) = { :query => value }.merge() if field.is_a?(Array) @value = { :multi_match => .merge( :fields => field ) } else @value = { :match => { field => } } end end |
Class Method Details
.add(query, field, value, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/tire/search/queries/match.rb', line 26 def self.add(query, field, value, ={}) 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, ).to_hash end |
Instance Method Details
#to_hash ⇒ Object
35 36 37 |
# File 'lib/tire/search/queries/match.rb', line 35 def to_hash @value end |