| | 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 FreshnessScoringFunction : IUtf8JsonSerializable |
| | 14 | | { |
| | 15 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 16 | | { |
| 0 | 17 | | writer.WriteStartObject(); |
| 0 | 18 | | writer.WritePropertyName("freshness"); |
| 0 | 19 | | writer.WriteObjectValue(Parameters); |
| 0 | 20 | | writer.WritePropertyName("type"); |
| 0 | 21 | | writer.WriteStringValue(Type); |
| 0 | 22 | | writer.WritePropertyName("fieldName"); |
| 0 | 23 | | writer.WriteStringValue(FieldName); |
| 0 | 24 | | writer.WritePropertyName("boost"); |
| 0 | 25 | | writer.WriteNumberValue(Boost); |
| 0 | 26 | | if (Optional.IsDefined(Interpolation)) |
| | 27 | | { |
| 0 | 28 | | writer.WritePropertyName("interpolation"); |
| 0 | 29 | | writer.WriteStringValue(Interpolation.Value.ToSerialString()); |
| | 30 | | } |
| 0 | 31 | | writer.WriteEndObject(); |
| 0 | 32 | | } |
| | 33 | |
|
| | 34 | | internal static FreshnessScoringFunction DeserializeFreshnessScoringFunction(JsonElement element) |
| | 35 | | { |
| 0 | 36 | | FreshnessScoringParameters freshness = default; |
| 0 | 37 | | string type = default; |
| 0 | 38 | | string fieldName = default; |
| 0 | 39 | | double boost = default; |
| 0 | 40 | | Optional<ScoringFunctionInterpolation> interpolation = default; |
| 0 | 41 | | foreach (var property in element.EnumerateObject()) |
| | 42 | | { |
| 0 | 43 | | if (property.NameEquals("freshness")) |
| | 44 | | { |
| 0 | 45 | | freshness = FreshnessScoringParameters.DeserializeFreshnessScoringParameters(property.Value); |
| 0 | 46 | | continue; |
| | 47 | | } |
| 0 | 48 | | if (property.NameEquals("type")) |
| | 49 | | { |
| 0 | 50 | | type = property.Value.GetString(); |
| 0 | 51 | | continue; |
| | 52 | | } |
| 0 | 53 | | if (property.NameEquals("fieldName")) |
| | 54 | | { |
| 0 | 55 | | fieldName = property.Value.GetString(); |
| 0 | 56 | | continue; |
| | 57 | | } |
| 0 | 58 | | if (property.NameEquals("boost")) |
| | 59 | | { |
| 0 | 60 | | boost = property.Value.GetDouble(); |
| 0 | 61 | | continue; |
| | 62 | | } |
| 0 | 63 | | if (property.NameEquals("interpolation")) |
| | 64 | | { |
| 0 | 65 | | interpolation = property.Value.GetString().ToScoringFunctionInterpolation(); |
| | 66 | | continue; |
| | 67 | | } |
| | 68 | | } |
| 0 | 69 | | return new FreshnessScoringFunction(type, fieldName, boost, Optional.ToNullable(interpolation), freshness); |
| | 70 | | } |
| | 71 | | } |
| | 72 | | } |