Class: ElasticQuery::FunctionScore

Inherits:
Query show all
Defined in:
lib/elastic_query/function_score.rb

Instance Attribute Summary collapse

Attributes inherited from Query

#query

Instance Method Summary collapse

Constructor Details

#initialize(query, functions, options = {}) ⇒ FunctionScore

Returns a new instance of FunctionScore.



5
6
7
8
9
# File 'lib/elastic_query/function_score.rb', line 5

def initialize(query, functions, options = {})
  @functions = functions
  @options = options
  super(query)
end

Instance Attribute Details

#functionsObject (readonly)

Returns the value of attribute functions.



3
4
5
# File 'lib/elastic_query/function_score.rb', line 3

def functions
  @functions
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/elastic_query/function_score.rb', line 3

def options
  @options
end

Instance Method Details

#to_hashObject



11
12
13
14
15
16
17
# File 'lib/elastic_query/function_score.rb', line 11

def to_hash
  {
    function_score: {
      query: query.to_hash,
    }.merge(functions.to_hash).merge(options)
  }
end