Class: FunctionScores::WeightedScoreFunctionBuilder

Inherits:
ScoreFunctionBuilder show all
Defined in:
lib/function_scores/weighted_score_function_builder.rb

Overview

A query that multiplies the weight to the score.

Instance Method Summary collapse

Methods inherited from ScoreFunctionBuilder

#name

Methods included from AttributesReader

#attributes

Constructor Details

#initializeWeightedScoreFunctionBuilder

Returns a new instance of WeightedScoreFunctionBuilder.



12
13
14
# File 'lib/function_scores/weighted_score_function_builder.rb', line 12

def initialize
  @weight = DEFAULT_WEIGHT
end

Instance Method Details

#functionHash

Returns serialized json query for the object.

Returns:

  • (Hash)

    serialized json query for the object



17
18
19
20
21
# File 'lib/function_scores/weighted_score_function_builder.rb', line 17

def function
  function = {}
  function[name.intern] = @weight
  function
end

#weight(value) ⇒ Object

Sets the weight value.



33
34
35
36
# File 'lib/function_scores/weighted_score_function_builder.rb', line 33

def weight(value)
  @weight = value
  self
end