         return lhs.type == rhs.type
             && lhs.field == rhs.field
             && lhs.origin == rhs.origin
-            && lhs.scale == rhs.origin
+            && lhs.scale == rhs.scale
             && lhs.offset == rhs.offset
             && lhs.decay == rhs.decay
             && lhs.multiValueMode == rhs.multiValueMode

            throw ScoreFunctionBuilderError.missingRequiredField("scale")
        }

        super.init(type: .exp, field: builder.field!, origin: builder.origin!, scale: builder.scale!, offset: builder.offset!, decay: builder.decay!, multiValueMode: builder.multiValueMode)
    }

    public required init(from decoder: Decoder) throws {

public struct RandomScoreFunction: ScoreFunction {
    public let scoreFunctionType: ScoreFunctionType = .randomScore

    public let seed: Int?
    public let field: String?

    public init(field: String? = nil, seed: Int? = nil) {
        self.seed = seed
        self.field = field
    }

    internal init(withBuilder builder: RandomScoreFunctionBuilder) throws {
//        guard builder.seed != nil else {
//            throw ScoreFunctionBuilderError.missingRequiredField("seed")
//        }
//
//        guard builder.field != nil else {
//            throw ScoreFunctionBuilderError.missingRequiredField("field")
//        }

        self.init(field: builder.field!, seed: builder.seed!)
    }

    public func toDic() -> [String: Any] {
        var dic: [String: Any] = [:]
        if let seed = self.seed {
            dic[CodingKeys.seed.rawValue] = seed
        }
        if let field = self.field {
            dic[CodingKeys.field.rawValue] = field
        }
        return [scoreFunctionType.rawValue: dic]
    }
}

