| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Text.Json; |
| | 9 | | using Azure.Core; |
| | 10 | |
|
| | 11 | | namespace Azure.Search.Documents.Indexes.Models |
| | 12 | | { |
| | 13 | | public partial class ShingleTokenFilter : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 0 | 17 | | writer.WriteStartObject(); |
| 0 | 18 | | if (Optional.IsDefined(MaxShingleSize)) |
| | 19 | | { |
| 0 | 20 | | writer.WritePropertyName("maxShingleSize"); |
| 0 | 21 | | writer.WriteNumberValue(MaxShingleSize.Value); |
| | 22 | | } |
| 0 | 23 | | if (Optional.IsDefined(MinShingleSize)) |
| | 24 | | { |
| 0 | 25 | | writer.WritePropertyName("minShingleSize"); |
| 0 | 26 | | writer.WriteNumberValue(MinShingleSize.Value); |
| | 27 | | } |
| 0 | 28 | | if (Optional.IsDefined(OutputUnigrams)) |
| | 29 | | { |
| 0 | 30 | | writer.WritePropertyName("outputUnigrams"); |
| 0 | 31 | | writer.WriteBooleanValue(OutputUnigrams.Value); |
| | 32 | | } |
| 0 | 33 | | if (Optional.IsDefined(OutputUnigramsIfNoShingles)) |
| | 34 | | { |
| 0 | 35 | | writer.WritePropertyName("outputUnigramsIfNoShingles"); |
| 0 | 36 | | writer.WriteBooleanValue(OutputUnigramsIfNoShingles.Value); |
| | 37 | | } |
| 0 | 38 | | if (Optional.IsDefined(TokenSeparator)) |
| | 39 | | { |
| 0 | 40 | | writer.WritePropertyName("tokenSeparator"); |
| 0 | 41 | | writer.WriteStringValue(TokenSeparator); |
| | 42 | | } |
| 0 | 43 | | if (Optional.IsDefined(FilterToken)) |
| | 44 | | { |
| 0 | 45 | | writer.WritePropertyName("filterToken"); |
| 0 | 46 | | writer.WriteStringValue(FilterToken); |
| | 47 | | } |
| 0 | 48 | | writer.WritePropertyName("@odata.type"); |
| 0 | 49 | | writer.WriteStringValue(ODataType); |
| 0 | 50 | | writer.WritePropertyName("name"); |
| 0 | 51 | | writer.WriteStringValue(Name); |
| 0 | 52 | | writer.WriteEndObject(); |
| 0 | 53 | | } |
| | 54 | |
|
| | 55 | | internal static ShingleTokenFilter DeserializeShingleTokenFilter(JsonElement element) |
| | 56 | | { |
| 0 | 57 | | Optional<int> maxShingleSize = default; |
| 0 | 58 | | Optional<int> minShingleSize = default; |
| 0 | 59 | | Optional<bool> outputUnigrams = default; |
| 0 | 60 | | Optional<bool> outputUnigramsIfNoShingles = default; |
| 0 | 61 | | Optional<string> tokenSeparator = default; |
| 0 | 62 | | Optional<string> filterToken = default; |
| 0 | 63 | | string odataType = default; |
| 0 | 64 | | string name = default; |
| 0 | 65 | | foreach (var property in element.EnumerateObject()) |
| | 66 | | { |
| 0 | 67 | | if (property.NameEquals("maxShingleSize")) |
| | 68 | | { |
| 0 | 69 | | maxShingleSize = property.Value.GetInt32(); |
| 0 | 70 | | continue; |
| | 71 | | } |
| 0 | 72 | | if (property.NameEquals("minShingleSize")) |
| | 73 | | { |
| 0 | 74 | | minShingleSize = property.Value.GetInt32(); |
| 0 | 75 | | continue; |
| | 76 | | } |
| 0 | 77 | | if (property.NameEquals("outputUnigrams")) |
| | 78 | | { |
| 0 | 79 | | outputUnigrams = property.Value.GetBoolean(); |
| 0 | 80 | | continue; |
| | 81 | | } |
| 0 | 82 | | if (property.NameEquals("outputUnigramsIfNoShingles")) |
| | 83 | | { |
| 0 | 84 | | outputUnigramsIfNoShingles = property.Value.GetBoolean(); |
| 0 | 85 | | continue; |
| | 86 | | } |
| 0 | 87 | | if (property.NameEquals("tokenSeparator")) |
| | 88 | | { |
| 0 | 89 | | tokenSeparator = property.Value.GetString(); |
| 0 | 90 | | continue; |
| | 91 | | } |
| 0 | 92 | | if (property.NameEquals("filterToken")) |
| | 93 | | { |
| 0 | 94 | | filterToken = property.Value.GetString(); |
| 0 | 95 | | continue; |
| | 96 | | } |
| 0 | 97 | | if (property.NameEquals("@odata.type")) |
| | 98 | | { |
| 0 | 99 | | odataType = property.Value.GetString(); |
| 0 | 100 | | continue; |
| | 101 | | } |
| 0 | 102 | | if (property.NameEquals("name")) |
| | 103 | | { |
| 0 | 104 | | name = property.Value.GetString(); |
| | 105 | | continue; |
| | 106 | | } |
| | 107 | | } |
| 0 | 108 | | return new ShingleTokenFilter(odataType, name, Optional.ToNullable(maxShingleSize), Optional.ToNullable(minS |
| | 109 | | } |
| | 110 | | } |
| | 111 | | } |