Class: Noiseless::AST::CombinedFields

Inherits:
Node
  • Object
show all
Defined in:
lib/noiseless/ast/combined_fields.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#to_h

Constructor Details

#initialize(query, fields, operator: nil, minimum_should_match: nil, zero_terms_query: nil, auto_generate_synonyms_phrase_query: nil) ⇒ CombinedFields

Returns a new instance of CombinedFields.



9
10
11
12
13
14
15
16
17
18
# File 'lib/noiseless/ast/combined_fields.rb', line 9

def initialize(query, fields, operator: nil, minimum_should_match: nil, zero_terms_query: nil,
               auto_generate_synonyms_phrase_query: nil)
  super()
  @query = query
  @fields = Array(fields).map(&:to_s)
  @operator = operator
  @minimum_should_match = minimum_should_match
  @zero_terms_query = zero_terms_query
  @auto_generate_synonyms_phrase_query = auto_generate_synonyms_phrase_query
end

Instance Attribute Details

#auto_generate_synonyms_phrase_queryObject (readonly)

Returns the value of attribute auto_generate_synonyms_phrase_query.



6
7
8
# File 'lib/noiseless/ast/combined_fields.rb', line 6

def auto_generate_synonyms_phrase_query
  @auto_generate_synonyms_phrase_query
end

#fieldsObject (readonly)

Returns the value of attribute fields.



6
7
8
# File 'lib/noiseless/ast/combined_fields.rb', line 6

def fields
  @fields
end

#minimum_should_matchObject (readonly)

Returns the value of attribute minimum_should_match.



6
7
8
# File 'lib/noiseless/ast/combined_fields.rb', line 6

def minimum_should_match
  @minimum_should_match
end

#operatorObject (readonly)

Returns the value of attribute operator.



6
7
8
# File 'lib/noiseless/ast/combined_fields.rb', line 6

def operator
  @operator
end

#queryObject (readonly)

Returns the value of attribute query.



6
7
8
# File 'lib/noiseless/ast/combined_fields.rb', line 6

def query
  @query
end

#zero_terms_queryObject (readonly)

Returns the value of attribute zero_terms_query.



6
7
8
# File 'lib/noiseless/ast/combined_fields.rb', line 6

def zero_terms_query
  @zero_terms_query
end

Instance Method Details

#optionsObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/noiseless/ast/combined_fields.rb', line 20

def options
  {}.tap do |opts|
    opts[:operator] = @operator if @operator
    opts[:minimum_should_match] = @minimum_should_match if @minimum_should_match
    opts[:zero_terms_query] = @zero_terms_query if @zero_terms_query
    unless @auto_generate_synonyms_phrase_query.nil?
      opts[:auto_generate_synonyms_phrase_query] =
        @auto_generate_synonyms_phrase_query
    end
  end
end