| | 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 BM25Similarity : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 2 | 17 | | writer.WriteStartObject(); |
| 2 | 18 | | if (Optional.IsDefined(K1)) |
| | 19 | | { |
| 0 | 20 | | if (K1 != null) |
| | 21 | | { |
| 0 | 22 | | writer.WritePropertyName("k1"); |
| 0 | 23 | | writer.WriteNumberValue(K1.Value); |
| | 24 | | } |
| | 25 | | else |
| | 26 | | { |
| 0 | 27 | | writer.WriteNull("k1"); |
| | 28 | | } |
| | 29 | | } |
| 2 | 30 | | if (Optional.IsDefined(B)) |
| | 31 | | { |
| 0 | 32 | | if (B != null) |
| | 33 | | { |
| 0 | 34 | | writer.WritePropertyName("b"); |
| 0 | 35 | | writer.WriteNumberValue(B.Value); |
| | 36 | | } |
| | 37 | | else |
| | 38 | | { |
| 0 | 39 | | writer.WriteNull("b"); |
| | 40 | | } |
| | 41 | | } |
| 2 | 42 | | writer.WritePropertyName("@odata.type"); |
| 2 | 43 | | writer.WriteStringValue(ODataType); |
| 2 | 44 | | writer.WriteEndObject(); |
| 2 | 45 | | } |
| | 46 | |
|
| | 47 | | internal static BM25Similarity DeserializeBM25Similarity(JsonElement element) |
| | 48 | | { |
| 16 | 49 | | Optional<double?> k1 = default; |
| 16 | 50 | | Optional<double?> b = default; |
| 16 | 51 | | string odataType = default; |
| 128 | 52 | | foreach (var property in element.EnumerateObject()) |
| | 53 | | { |
| 48 | 54 | | if (property.NameEquals("k1")) |
| | 55 | | { |
| 16 | 56 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 57 | | { |
| 16 | 58 | | k1 = null; |
| 16 | 59 | | continue; |
| | 60 | | } |
| 0 | 61 | | k1 = property.Value.GetDouble(); |
| 0 | 62 | | continue; |
| | 63 | | } |
| 32 | 64 | | if (property.NameEquals("b")) |
| | 65 | | { |
| 16 | 66 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 67 | | { |
| 16 | 68 | | b = null; |
| 16 | 69 | | continue; |
| | 70 | | } |
| 0 | 71 | | b = property.Value.GetDouble(); |
| 0 | 72 | | continue; |
| | 73 | | } |
| 16 | 74 | | if (property.NameEquals("@odata.type")) |
| | 75 | | { |
| 16 | 76 | | odataType = property.Value.GetString(); |
| | 77 | | continue; |
| | 78 | | } |
| | 79 | | } |
| 16 | 80 | | return new BM25Similarity(odataType, Optional.ToNullable(k1), Optional.ToNullable(b)); |
| | 81 | | } |
| | 82 | | } |
| | 83 | | } |