Class: FunctionScores::RandomScoreFunctionBuilder

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

Overview

A function that computes a random score for the matched documents

Query Components:
  seed: Seed value based on which the random number will be generated
  field: Field value based on which the random number will be generated

Instance Method Summary collapse

Methods inherited from ScoreFunctionBuilder

#name

Methods included from AttributesReader

#attributes

Instance Method Details

#field(value) ⇒ RandomScoreFunctionBuilder

Sets the field value. modified self



48
49
50
51
# File 'lib/function_scores/random_score_function_builder.rb', line 48

def field(value)
  @field = value
  self
end

#functionHash

Returns serailized json query for the object.

Returns:

  • (Hash)

    serailized json query for the object



14
15
16
17
18
19
20
21
# File 'lib/function_scores/random_score_function_builder.rb', line 14

def function
  function = {}
  rs_query = super
  rs_query[:field] = @field if field.present?
  rs_query[:seed] = @seed if seed.present?
  function[name.intern] = rs_query
  function
end

#seed(value) ⇒ RandomScoreFunctionBuilder

Sets the seed value. modified self



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

def seed(value)
  @seed = value
  self
end