     public init(from decoder: Decoder) throws {
         let container = try decoder.container(keyedBy: DynamicCodingKeys.self)
         let nested = try container.nestedContainer(keyedBy: CodingKeys.self, forKey: .key(named: scoreFunctionType))
-        seed = try nested.decodeInt(forKey: .seed)
-        field = try nested.decodeString(forKey: .field)
+        seed = try nested.decodeIntIfPresent(forKey: .seed)
+        field = try nested.decodeStringIfPresent(forKey: .field)
     }
 
     public func encode(to encoder: Encoder) throws {
         var container = encoder.container(keyedBy: DynamicCodingKeys.self)
         var nested = container.nestedContainer(keyedBy: CodingKeys.self, forKey: .key(named: scoreFunctionType))
-        try nested.encode(seed, forKey: .seed)
-        try nested.encode(field, forKey: .field)
+        try nested.encodeIfPresent(seed, forKey: .seed)
+        try nested.encodeIfPresent(field, forKey: .field)
     }
 
     enum CodingKeys: String, CodingKey {

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

            throw ScoreFunctionBuilderError.missingRequiredField("scale")
        }

        super.init(type: .gauss, 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 {
