Class: Stretchy::Builders::BoostBuilder
- Inherits:
-
Object
- Object
- Stretchy::Builders::BoostBuilder
- Defined in:
- lib/stretchy/builders/boost_builder.rb
Instance Attribute Summary collapse
-
#boost_mode ⇒ Object
Returns the value of attribute boost_mode.
-
#functions ⇒ Object
Returns the value of attribute functions.
-
#max_boost ⇒ Object
Returns the value of attribute max_boost.
-
#overall_boost ⇒ Object
Returns the value of attribute overall_boost.
-
#score_mode ⇒ Object
Returns the value of attribute score_mode.
Instance Method Summary collapse
- #any? ⇒ Boolean
-
#initialize ⇒ BoostBuilder
constructor
A new instance of BoostBuilder.
- #to_search(query_or_filter) ⇒ Object
Constructor Details
#initialize ⇒ BoostBuilder
Returns a new instance of BoostBuilder.
7 8 9 10 11 12 13 |
# File 'lib/stretchy/builders/boost_builder.rb', line 7 def initialize @functions = [] @overall_boost = nil @max_boost = nil @score_mode = 'sum' @boost_mode = 'sum' end |
Instance Attribute Details
#boost_mode ⇒ Object
Returns the value of attribute boost_mode.
5 6 7 |
# File 'lib/stretchy/builders/boost_builder.rb', line 5 def boost_mode @boost_mode end |
#functions ⇒ Object
Returns the value of attribute functions.
5 6 7 |
# File 'lib/stretchy/builders/boost_builder.rb', line 5 def functions @functions end |
#max_boost ⇒ Object
Returns the value of attribute max_boost.
5 6 7 |
# File 'lib/stretchy/builders/boost_builder.rb', line 5 def max_boost @max_boost end |
#overall_boost ⇒ Object
Returns the value of attribute overall_boost.
5 6 7 |
# File 'lib/stretchy/builders/boost_builder.rb', line 5 def overall_boost @overall_boost end |
#score_mode ⇒ Object
Returns the value of attribute score_mode.
5 6 7 |
# File 'lib/stretchy/builders/boost_builder.rb', line 5 def score_mode @score_mode end |
Instance Method Details
#any? ⇒ Boolean
15 16 17 |
# File 'lib/stretchy/builders/boost_builder.rb', line 15 def any? @functions.any? end |
#to_search(query_or_filter) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/stretchy/builders/boost_builder.rb', line 19 def to_search(query_or_filter) = { functions: @functions, score_mode: @score_mode, boost_mode: @boost_mode } [:overall_boost] = @overall_boost if @overall_boost [:max_boost] = @max_boost if @max_boost [:query] = query_or_filter if query_or_filter.is_a?(Stretchy::Queries::Base) [:filter] = query_or_filter if query_or_filter.is_a?(Stretchy::Filters::Base) Stretchy::Queries::FunctionScoreQuery.new() end |