Project.search do case params[:type] when 'healthy' with(:health_score, 80..100) # => [80, 81, ... , 99, 100] when 'at_risk' with(:health_score, 50...80) # => [50, 51, ... , 79, 80] - should not inlcude 80, inner Sunspot Range evaluation error end # possible fix: case params[:type] when 'healthy' with(:health_score, (80..100).to_a) # => [80, 81, ... , 99, 100] when 'at_risk' with(:health_score, (50...80).to_a) # => [50, 51, ... , 79] - all good when preventing sunspot from evaluating Range object end end