Class: Stretchy::Boosts::RandomBoost

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

Constant Summary

Constants inherited from Base

Base::DEFAULT_WEIGHT

Instance Method Summary collapse

Methods included from Utils::Validation

#errors, included, #json_attributes, #require_one!, #require_only_one!, #valid?, #validate!, #validator

Constructor Details

#initialize(seed, weight = nil) ⇒ RandomBoost

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



18
19
20
21
22
# File 'lib/stretchy/boosts/random_boost.rb', line 18

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

Instance Method Details

#to_searchObject



24
25
26
27
28
29
30
31
# File 'lib/stretchy/boosts/random_boost.rb', line 24

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