Class: ElasticsearchDslBuilder::DSL::Search::Queries::MultiMatch
- Defined in:
- lib/elasticsearch_dsl_builder/dsl/search/queries/multi_match.rb
Instance Attribute Summary
Attributes inherited from Query
Instance Method Summary collapse
- #fields(*fields) ⇒ Object
-
#initialize(fields = nil, value = nil) ⇒ MultiMatch
constructor
A new instance of MultiMatch.
- #to_hash ⇒ Object
- #value(value) ⇒ Object
Constructor Details
#initialize(fields = nil, value = nil) ⇒ MultiMatch
Returns a new instance of MultiMatch.
6 7 8 9 10 11 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/multi_match.rb', line 6 def initialize(fields = nil, value = nil) @type = :multi_match fields(fields) value(value) super() end |
Instance Method Details
#fields(*fields) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/multi_match.rb', line 13 def fields(*fields) fields = fields.flatten valid = !fields.empty? && fields.all? { |f| f.instance_of?(String) } raise ArgumentError, 'fields must be array of Strings' unless valid @fields = fields self end |
#to_hash ⇒ Object
27 28 29 30 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/multi_match.rb', line 27 def to_hash @query = { fields: @fields, query: @value } if @fields && @value super end |
#value(value) ⇒ Object
21 22 23 24 25 |
# File 'lib/elasticsearch_dsl_builder/dsl/search/queries/multi_match.rb', line 21 def value(value) raise ArgumentError, 'value must be a String' unless value.instance_of?(String) @value = value self end |