| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.Text.Json; |
| | 5 | | using Azure.Core; |
| | 6 | |
|
| | 7 | | namespace Azure.Search.Documents.Indexes.Models |
| | 8 | | { |
| | 9 | | [CodeGenModel("LuceneStandardTokenizerV2")] |
| | 10 | | [CodeGenSuppress(nameof(LuceneStandardTokenizer), typeof(string), typeof(string), typeof(int?))] |
| | 11 | | public partial class LuceneStandardTokenizer : IUtf8JsonSerializable |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Initializes a new instance of LuceneStandardTokenizer. |
| | 15 | | /// </summary> |
| | 16 | | /// <param name="name"> |
| | 17 | | /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, |
| | 18 | | /// can only start and end with alphanumeric characters, and is limited to 128 characters. |
| | 19 | | /// </param> |
| 3 | 20 | | public LuceneStandardTokenizer(string name) : base(name) |
| | 21 | | { |
| 3 | 22 | | Argument.AssertNotNull(name, nameof(name)); |
| | 23 | |
|
| 3 | 24 | | ODataType = "#Microsoft.Azure.Search.StandardTokenizerV2"; |
| 3 | 25 | | } |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// The maximum token length. Default is 255. |
| | 29 | | /// Tokens longer than the maximum length are split. |
| | 30 | | /// The maximum token length that can be used is 300 characters. |
| | 31 | | /// </summary> |
| 8 | 32 | | public int? MaxTokenLength { get; set; } |
| | 33 | |
|
| | 34 | | void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 35 | | { |
| 2 | 36 | | writer.WriteStartObject(); |
| 2 | 37 | | if (MaxTokenLength != null) |
| | 38 | | { |
| 2 | 39 | | writer.WritePropertyName("maxTokenLength"); |
| 2 | 40 | | writer.WriteNumberValue(MaxTokenLength.Value); |
| | 41 | | } |
| 2 | 42 | | writer.WritePropertyName("@odata.type"); |
| 2 | 43 | | writer.WriteStringValue(ODataType); |
| 2 | 44 | | writer.WritePropertyName("name"); |
| 2 | 45 | | writer.WriteStringValue(Name); |
| 2 | 46 | | writer.WriteEndObject(); |
| 2 | 47 | | } |
| | 48 | |
|
| | 49 | | internal static LuceneStandardTokenizer DeserializeLuceneStandardTokenizer(JsonElement element) |
| | 50 | | { |
| 2 | 51 | | int? maxTokenLength = default; |
| 2 | 52 | | string odataType = default; |
| 2 | 53 | | string name = default; |
| | 54 | |
|
| 16 | 55 | | foreach (var property in element.EnumerateObject()) |
| | 56 | | { |
| 6 | 57 | | if (property.NameEquals("@odata.type")) |
| | 58 | | { |
| 2 | 59 | | odataType = property.Value.GetString(); |
| 2 | 60 | | continue; |
| | 61 | | } |
| | 62 | |
|
| 4 | 63 | | if (property.NameEquals("name")) |
| | 64 | | { |
| 2 | 65 | | name = property.Value.GetString(); |
| 2 | 66 | | continue; |
| | 67 | | } |
| | 68 | |
|
| 2 | 69 | | if (property.NameEquals("maxTokenLength")) |
| | 70 | | { |
| 2 | 71 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 72 | | { |
| | 73 | | continue; |
| | 74 | | } |
| 2 | 75 | | maxTokenLength = property.Value.GetInt32(); |
| | 76 | | continue; |
| | 77 | | } |
| | 78 | | } |
| | 79 | |
|
| 2 | 80 | | return new LuceneStandardTokenizer(name) |
| 2 | 81 | | { |
| 2 | 82 | | ODataType = odataType, |
| 2 | 83 | | MaxTokenLength = maxTokenLength, |
| 2 | 84 | | }; |
| | 85 | | } |
| | 86 | | } |
| | 87 | | } |