Пример #1
0
        public FreshnessScoringFunction(string fieldName, double boost, FreshnessScoringParameters parameters) : base(fieldName, boost)
        {
            if (fieldName == null)
            {
                throw new ArgumentNullException(nameof(fieldName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            Parameters = parameters;
            Type       = "freshness";
        }
Пример #2
0
        internal static FreshnessScoringFunction DeserializeFreshnessScoringFunction(JsonElement element)
        {
            FreshnessScoringParameters freshness = default;
            string type      = default;
            string fieldName = default;
            double boost     = default;
            ScoringFunctionInterpolation?interpolation = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("freshness"))
                {
                    freshness = FreshnessScoringParameters.DeserializeFreshnessScoringParameters(property.Value);
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("fieldName"))
                {
                    fieldName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("boost"))
                {
                    boost = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("interpolation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    interpolation = property.Value.GetString().ToScoringFunctionInterpolation();
                    continue;
                }
            }
            return(new FreshnessScoringFunction(type, fieldName, boost, interpolation, freshness));
        }
Пример #3
0
 internal FreshnessScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation?interpolation, FreshnessScoringParameters parameters) : base(type, fieldName, boost, interpolation)
 {
     Parameters = parameters;
     Type       = type ?? "freshness";
 }