Class: Elasticquery::Queries::MultiMatch
- Defined in:
- lib/elasticquery/queries/multi_match.rb
Constant Summary collapse
- OPERATORS =
%w(and or)- TYPES =
%w(best_fields most_fields cross_fields phrase pharse_prefix)
Instance Method Summary collapse
-
#initialize(query, fields: "_all", operator: "and", type: "best_fields") ⇒ MultiMatch
constructor
A new instance of MultiMatch.
- #to_hash ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(query, fields: "_all", operator: "and", type: "best_fields") ⇒ MultiMatch
9 10 11 12 13 14 |
# File 'lib/elasticquery/queries/multi_match.rb', line 9 def initialize(query, fields: "_all", operator: "and", type: "best_fields") @fields = fields @operator = operator @type = type @query = query end |
Instance Method Details
#to_hash ⇒ Object
23 24 25 |
# File 'lib/elasticquery/queries/multi_match.rb', line 23 def to_hash {multi_match: subquery} end |
#valid? ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/elasticquery/queries/multi_match.rb', line 16 def valid? OPERATORS.include?(@operator) && TYPES.include?(@type) && @query.present? && ( Array === @fields || @fields == "_all" ) end |