Class: Stretchy::Boosts::RandomBoost

Inherits:
Base
  • Object
show all
Defined in:
lib/stretchy/boosts/random_boost.rb

Constant Summary collapse

DEFAULT_WEIGHT =
1.2

Constants inherited from Base

Base::DEFAULT_DECAY_FN

Constants included from Utils::Contract

Utils::Contract::ASSERTIONS, Utils::Contract::DECAY_FUNCTIONS, Utils::Contract::DISTANCE_FORMAT

Instance Method Summary collapse

Methods included from Utils::Contract

included, #require_one, #validate!

Constructor Details

#initialize(seed, weight = nil) ⇒ RandomBoost

randomizes order (somewhat) consistently per-user www.elastic.co/guide/en/elasticsearch/guide/current/random-scoring.html



15
16
17
18
19
# File 'lib/stretchy/boosts/random_boost.rb', line 15

def initialize(seed, weight = nil)
  @seed   = seed
  @weight = weight || DEFAULT_WEIGHT
  validate!
end

Instance Method Details

#to_searchObject



21
22
23
24
25
26
27
28
# File 'lib/stretchy/boosts/random_boost.rb', line 21

def to_search
  {
    random_score: {
      seed: @seed
    },
    weight: @weight
  }
end