machinio/solrb

View on GitHub
lib/solr/query/request/boosting/field_value_less_than_boost_function.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Solr
  module Query
    class Request
      class Boosting
        class FieldValueLessThanBoostFunction
          include Solr::Support::SchemaHelper

          attr_reader :field, :max, :boost_magnitude

          def initialize(field:, max:, boost_magnitude:)
            @field = field
            @max = max
            @boost_magnitude = boost_magnitude
            freeze
          end

          def to_solr_s
            solr_field = solarize_field(field)
            "if(sub(#{max},max(#{solr_field},#{max})),1,#{boost_magnitude})"
          end
        end
      end
    end
  end
end