/// <summary> Initializes a new instance of TagScoringFunction. </summary>
        /// <param name="fieldName"> The name of the field used as input to the scoring function. </param>
        /// <param name="boost"> A multiplier for the raw score. Must be a positive number not equal to 1.0. </param>
        /// <param name="parameters"> Parameter values for the tag scoring function. </param>
        /// <exception cref="ArgumentException"><paramref name="fieldName"/> is an empty string.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="fieldName"/> or <paramref name="parameters"/> is null.</exception>
        public TagScoringFunction(string fieldName, double boost, TagScoringParameters parameters) : base(fieldName, boost)
        {
            Argument.AssertNotNullOrEmpty(fieldName, nameof(fieldName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            Parameters = parameters;
            Type       = "tag";
        }
示例#2
0
        internal static TagScoringParameters DeserializeTagScoringParameters(JsonElement element)
        {
            TagScoringParameters result = new TagScoringParameters();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("tagsParameter"))
                {
                    result.TagsParameter = property.Value.GetString();
                    continue;
                }
            }
            return(result);
        }
示例#3
0
        public TagScoringFunction(string fieldName, double boost, TagScoringParameters parameters) : base(fieldName, boost)
        {
            if (fieldName == null)
            {
                throw new ArgumentNullException(nameof(fieldName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            Parameters = parameters;
            Type       = "tag";
        }
示例#4
0
        internal static TagScoringFunction DeserializeTagScoringFunction(JsonElement element)
        {
            TagScoringParameters tag = default;
            string type      = default;
            string fieldName = default;
            double boost     = default;
            ScoringFunctionInterpolation?interpolation = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("tag"))
                {
                    tag = TagScoringParameters.DeserializeTagScoringParameters(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 TagScoringFunction(tag, type, fieldName, boost, interpolation));
        }
        internal static TagScoringFunction DeserializeTagScoringFunction(JsonElement element)
        {
            TagScoringFunction result = new TagScoringFunction();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("tag"))
                {
                    result.Parameters = TagScoringParameters.DeserializeTagScoringParameters(property.Value);
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    result.Type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("fieldName"))
                {
                    result.FieldName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("boost"))
                {
                    result.Boost = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("interpolation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Interpolation = property.Value.GetString().ToScoringFunctionInterpolation();
                    continue;
                }
            }
            return(result);
        }
示例#6
0
 internal TagScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation?interpolation, TagScoringParameters parameters) : base(type, fieldName, boost, interpolation)
 {
     Parameters = parameters;
     Type       = type ?? "tag";
 }