Exemple #1
0
 internal CustomAnalyzer(string oDataType, string name, LexicalTokenizerName tokenizer, IList <TokenFilterName> tokenFilters, IList <string> charFilters) : base(oDataType, name)
 {
     Tokenizer    = tokenizer;
     TokenFilters = tokenFilters;
     CharFilters  = charFilters;
     ODataType    = oDataType ?? "#Microsoft.Azure.Search.CustomAnalyzer";
 }
Exemple #2
0
        public CustomAnalyzer(string name, LexicalTokenizerName tokenizer) : base(name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            Tokenizer = tokenizer;
            ODataType = "#Microsoft.Azure.Search.CustomAnalyzer";
        }
Exemple #3
0
        internal static CustomAnalyzer DeserializeCustomAnalyzer(JsonElement element)
        {
            LexicalTokenizerName    tokenizer    = default;
            IList <TokenFilterName> tokenFilters = default;
            IList <string>          charFilters  = default;
            string odataType = default;
            string name      = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("tokenizer"))
                {
                    tokenizer = new LexicalTokenizerName(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("tokenFilters"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <TokenFilterName> array = new List <TokenFilterName>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(new TokenFilterName(item.GetString()));
                    }
                    tokenFilters = array;
                    continue;
                }
                if (property.NameEquals("charFilters"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    charFilters = array;
                    continue;
                }
                if (property.NameEquals("@odata.type"))
                {
                    odataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
            }
            return(new CustomAnalyzer(odataType, name, tokenizer, tokenFilters, charFilters));
        }