< Summary

Class:Azure.Search.Documents.Indexes.Models.ScoringFunction
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\ScoringFunction.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\ScoringFunction.Serialization.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\ScoringFunction.cs
Covered lines:17
Uncovered lines:32
Coverable lines:49
Total lines:134
Line coverage:34.6% (17 of 49)
Covered branches:3
Total branches:24
Branch coverage:12.5% (3 of 24)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_Type()-100%100%
get_FieldName()-100%100%
get_Boost()-100%100%
get_Interpolation()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-0%0%
DeserializeScoringFunction(...)-13.04%10%
.ctor(...)-100%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\ScoringFunction.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9
 10namespace Azure.Search.Documents.Indexes.Models
 11{
 12    /// <summary> Base type for functions that can modify document scores during ranking. </summary>
 13    public partial class ScoringFunction
 14    {
 15
 16        /// <summary> Initializes a new instance of ScoringFunction. </summary>
 17        /// <param name="type"> Indicates the type of function to use. Valid values include magnitude, freshness, distan
 18        /// <param name="fieldName"> The name of the field used as input to the scoring function. </param>
 19        /// <param name="boost"> A multiplier for the raw score. Must be a positive number not equal to 1.0. </param>
 20        /// <param name="interpolation"> A value indicating how boosting will be interpolated across document scores; de
 1021        internal ScoringFunction(string type, string fieldName, double boost, ScoringFunctionInterpolation? interpolatio
 22        {
 1023            Type = type;
 1024            FieldName = fieldName;
 1025            Boost = boost;
 1026            Interpolation = interpolation;
 1027        }
 28
 29        /// <summary> Indicates the type of function to use. Valid values include magnitude, freshness, distance, and ta
 3030        internal string Type { get; set; }
 31        /// <summary> The name of the field used as input to the scoring function. </summary>
 2032        public string FieldName { get; set; }
 33        /// <summary> A multiplier for the raw score. Must be a positive number not equal to 1.0. </summary>
 2034        public double Boost { get; set; }
 35        /// <summary> A value indicating how boosting will be interpolated across document scores; defaults to &quot;Lin
 1836        public ScoringFunctionInterpolation? Interpolation { get; set; }
 37    }
 38}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\ScoringFunction.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Text.Json;
 9using Azure.Core;
 10
 11namespace Azure.Search.Documents.Indexes.Models
 12{
 13    public partial class ScoringFunction : IUtf8JsonSerializable
 14    {
 15        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 16        {
 017            writer.WriteStartObject();
 018            writer.WritePropertyName("type");
 019            writer.WriteStringValue(Type);
 020            writer.WritePropertyName("fieldName");
 021            writer.WriteStringValue(FieldName);
 022            writer.WritePropertyName("boost");
 023            writer.WriteNumberValue(Boost);
 024            if (Optional.IsDefined(Interpolation))
 25            {
 026                writer.WritePropertyName("interpolation");
 027                writer.WriteStringValue(Interpolation.Value.ToSerialString());
 28            }
 029            writer.WriteEndObject();
 030        }
 31
 32        internal static ScoringFunction DeserializeScoringFunction(JsonElement element)
 33        {
 1034            if (element.TryGetProperty("type", out JsonElement discriminator))
 35            {
 1036                switch (discriminator.GetString())
 37                {
 1038                    case "distance": return DistanceScoringFunction.DeserializeDistanceScoringFunction(element);
 039                    case "freshness": return FreshnessScoringFunction.DeserializeFreshnessScoringFunction(element);
 040                    case "magnitude": return MagnitudeScoringFunction.DeserializeMagnitudeScoringFunction(element);
 041                    case "tag": return TagScoringFunction.DeserializeTagScoringFunction(element);
 42                }
 43            }
 044            string type = default;
 045            string fieldName = default;
 046            double boost = default;
 047            Optional<ScoringFunctionInterpolation> interpolation = default;
 048            foreach (var property in element.EnumerateObject())
 49            {
 050                if (property.NameEquals("type"))
 51                {
 052                    type = property.Value.GetString();
 053                    continue;
 54                }
 055                if (property.NameEquals("fieldName"))
 56                {
 057                    fieldName = property.Value.GetString();
 058                    continue;
 59                }
 060                if (property.NameEquals("boost"))
 61                {
 062                    boost = property.Value.GetDouble();
 063                    continue;
 64                }
 065                if (property.NameEquals("interpolation"))
 66                {
 067                    interpolation = property.Value.GetString().ToScoringFunctionInterpolation();
 68                    continue;
 69                }
 70            }
 071            return new ScoringFunction(type, fieldName, boost, Optional.ToNullable(interpolation));
 72        }
 73    }
 74}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\ScoringFunction.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5
 6namespace Azure.Search.Documents.Indexes.Models
 7{
 8    public partial class ScoringFunction
 9    {
 10        /// <summary>
 11        /// Creates a new instance of the <see cref="ScoringFunction"/> class.
 12        /// </summary>
 13        /// <param name="fieldName">The name of the field used as input to the scoring function.</param>
 14        /// <param name="boost">A multiplier for the raw score. Must be a positive number not equal to 1.0.</param>
 15        /// <exception cref="ArgumentNullException"><paramref name="fieldName"/> is null.</exception>
 416        private protected ScoringFunction(string fieldName, double boost)
 17        {
 418            FieldName = fieldName ?? throw new ArgumentNullException(nameof(fieldName));
 419            Boost = boost;
 420        }
 21    }
 22}