< Summary

Class:Azure.Search.Documents.Indexes.Models.SearchSuggester
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchSuggester.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchSuggester.Serialization.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\SearchSuggester.cs
Covered lines:44
Uncovered lines:0
Coverable lines:44
Total lines:145
Line coverage:100% (44 of 44)
Covered branches:12
Total branches:12
Branch coverage:100% (12 of 12)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_Name()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-100%100%
DeserializeSearchSuggester(...)-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
get_SourceFields()-100%100%
get_SearchMode()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchSuggester.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;
 9using System.Collections.Generic;
 10using System.Linq;
 11
 12namespace Azure.Search.Documents.Indexes.Models
 13{
 14    /// <summary> Defines how the Suggest API should apply to a group of fields in the index. </summary>
 15    public partial class SearchSuggester
 16    {
 17
 18        /// <summary> Initializes a new instance of SearchSuggester. </summary>
 19        /// <param name="name"> The name of the suggester. </param>
 20        /// <param name="searchMode"> A value indicating the capabilities of the suggester. </param>
 21        /// <param name="sourceFields"> The list of field names to which the suggester applies. Each field must be searc
 1522        internal SearchSuggester(string name, string searchMode, IList<string> sourceFields)
 23        {
 1524            Name = name;
 1525            SearchMode = searchMode;
 1526            SourceFields = sourceFields;
 1527        }
 28
 29        /// <summary> The name of the suggester. </summary>
 3930        public string Name { get; set; }
 31    }
 32}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchSuggester.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.Collections.Generic;
 9using System.Text.Json;
 10using Azure.Core;
 11
 12namespace Azure.Search.Documents.Indexes.Models
 13{
 14    public partial class SearchSuggester : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 918            writer.WriteStartObject();
 919            writer.WritePropertyName("name");
 920            writer.WriteStringValue(Name);
 921            writer.WritePropertyName("searchMode");
 922            writer.WriteStringValue(SearchMode);
 923            writer.WritePropertyName("sourceFields");
 924            writer.WriteStartArray();
 4825            foreach (var item in SourceFields)
 26            {
 1527                writer.WriteStringValue(item);
 28            }
 929            writer.WriteEndArray();
 930            writer.WriteEndObject();
 931        }
 32
 33        internal static SearchSuggester DeserializeSearchSuggester(JsonElement element)
 34        {
 1535            string name = default;
 1536            string searchMode = default;
 1537            IList<string> sourceFields = default;
 12038            foreach (var property in element.EnumerateObject())
 39            {
 4540                if (property.NameEquals("name"))
 41                {
 1542                    name = property.Value.GetString();
 1543                    continue;
 44                }
 3045                if (property.NameEquals("searchMode"))
 46                {
 1547                    searchMode = property.Value.GetString();
 1548                    continue;
 49                }
 1550                if (property.NameEquals("sourceFields"))
 51                {
 1552                    List<string> array = new List<string>();
 8453                    foreach (var item in property.Value.EnumerateArray())
 54                    {
 2755                        array.Add(item.GetString());
 56                    }
 1557                    sourceFields = array;
 58                    continue;
 59                }
 60            }
 1561            return new SearchSuggester(name, searchMode, sourceFields);
 62        }
 63    }
 64}

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Linq;
 7using Azure.Core;
 8
 9namespace Azure.Search.Documents.Indexes.Models
 10{
 11    [CodeGenModel("Suggester")]
 12    public partial class SearchSuggester
 13    {
 14        private const string AnalyzingInfixMatching = "analyzingInfixMatching";
 15
 16        /// <summary>
 17        /// Creates a new instance of the <see cref="SearchSuggester"/> class.
 18        /// </summary>
 19        /// <param name="name">The name of the suggester.</param>
 20        /// <param name="sourceFields">The list of field names to which the suggester applies. Each field must be search
 21        /// <exception cref="ArgumentException"><paramref name="name"/> is an empty string.</exception>
 22        /// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="sourceFields"/> is null.<
 723        public SearchSuggester(string name, IEnumerable<string> sourceFields)
 24        {
 725            Argument.AssertNotNullOrEmpty(name, nameof(name));
 726            Argument.AssertNotNullOrEmpty(sourceFields, nameof(sourceFields));
 27
 728            Name = name;
 729            SourceFields = sourceFields.ToList();
 730        }
 31
 32        /// <summary>
 33        /// Creates a new instance of the <see cref="SearchSuggester"/> class.
 34        /// </summary>
 35        /// <param name="name">The name of the suggester.</param>
 36        /// <param name="sourceFields">The list of field names to which the suggester applies. Each field must be search
 37        /// <exception cref="ArgumentException"><paramref name="name"/> is an empty string.</exception>
 38        /// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="sourceFields"/> is null.<
 739        public SearchSuggester(string name, params string[] sourceFields) : this(name, (IEnumerable<string>)sourceFields
 40        {
 741        }
 42
 43        /// <summary> The list of field names to which the suggester applies. Each field must be searchable. </summary>
 944        public IList<string> SourceFields { get; }
 45
 46        [CodeGenMember("searchMode")]
 3147        private string SearchMode { get; } = AnalyzingInfixMatching;
 48    }
 49}