Class: Stretchy::Boosts::RandomBoost
- Defined in:
- lib/stretchy/boosts/random_boost.rb
Constant Summary collapse
- DEFAULT_WEIGHT =
1.2
Constants inherited from Base
Constants included from Utils::Contract
Utils::Contract::ASSERTIONS, Utils::Contract::DECAY_FUNCTIONS, Utils::Contract::DISTANCE_FORMAT
Instance Method Summary collapse
-
#initialize(seed, weight = nil) ⇒ RandomBoost
constructor
randomizes order (somewhat) consistently per-user www.elastic.co/guide/en/elasticsearch/guide/current/random-scoring.html.
- #to_search ⇒ Object
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_search ⇒ Object
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 |